|
主题: director应用技巧
|
 donlee
职务:普通成员
等级:1
金币:1.0
发贴:271
注册:2000/12/8 8:52:18
|
#12001/6/14 15:41:52
director应用技巧
1、设置movie,使之自动缩放以适应屏幕大小 A:使用如下script: on preparemovie (the stage).rect=(the desktoprectlist)[1] (the stage).drawrect=(the desktoprectlist)[1] end
2、制作带阴影效果的text field可以作出阴影效果,但在field中应用中文容易死机,我们可以用一个text member但多个sprite,各sprite位置稍稍错开,并适当设置其blend即可。灵活使用之可以得到动态的和彩色的阴影。缺点是数量过多会拖累速度。
3、中文菜单 可以用installmenu的标准方法生成中文菜单,但字体、字号设置全部无效。
4、filmloop播放问题:在一帧内判断一个filmloop播放完毕,再继续播放下一帧。 frame script中含有以下代码,以实现"定格": on exitframe me go the frame end 再把以下behavior拖到filmloop sprite即可: on exitframe me --但用prepareframe不行?! tell sprite(me.spriteNum) if the frame = the lastframe then ploopcnt = 1 end if end tell if ploopcnt then go next --或改为其它命令 end if end
5、对filmloop的控制。 以下behavior的功能是用于一个filmloop sprite,点击暂停,再次点击则继续。 property ppause,pframe on beginsprite me ppause=false pframe=1 end
on mouseup me ppause=not ppause if ppause then tell sprite(me.spriteNum) to pframe=the frame end if end
on exitframe me if ppause then if pframe=1 then tell sprite(me.spriteNum) to go to the lastframe else tell sprite(me.spriteNum) to go to pframe-1 end if end if end 由此我们也可以知道,我们无法使filmloop的播放速度快于movie,但可以用上法的变通来减慢它。 补充说明:tell sprite...用法类似tell window,但尚未见于正式文档,我使用至今,尚未见其出错。
6、在projector用lingo关闭计算机(用于Windows9X),主要用于触摸屏等无人值守的情况等。 A:无论此时计算机是否有打开的程序或窗口,使用下面的lingo语句可直接关机:(仅限于projector) open "c:\windows\rundll.exe user.exe,exitwindows" 若要重新启动计算机,改为 "c:\windows\rundll.exe user.exe ,exitwindowsexec" 当然在实际的projector中不能直接用"c:\windows",而要用fileio的getosdirectory()等函数先获得系统相应目录。
7、在runtime动态地改为Director内置的图标 最常用和简单的方法是对于一个sprite,施与以下behavior: on beginsprite me sprite(me.spriteNum).cursor=280 --手形光标 end 一般的光标设置以上一句就够了,更具个性化的光标设置这里不谈了。
内置图标(有些是相同的):0-4 200 254 256-269 271-272 280-281 284-286 290-304
8、Lingo支持递归! 用到搜索算法的朋友们应该高兴吧。
9、director中事件发生的顺序
prepareMovie beginsprite for frame 1 stepFrame for frame 1 prepareframe for frame 1 startMovie enterFrame for frmae 1 exitfrmae for frame 1
beginsprite for next frame
10、设置搜索路径的合适位置 A:实际上,在prepareMovie前,所用到的cast及相关的member包括其链接关系都应作好准备。 所以不可在movie内为自身设置搜索路径。一般在stub player中设置searchpath为佳。
|
 lovem
职务:普通成员
等级:1
金币:0.0
发贴:38
注册:2001/3/25 15:13:06
|
#22001/6/14 17:22:17
我也来凑凑热闹,谈一点经验吧,呵呵。
1、""&A 就可以将数字A转换为字符串。 A=123 put ""&A --"123" 2、数字字符串与数字相加,得浮点数,如 put "5"+3 -- 8.0000 故在游戏中显示步骤时应注意。 3、由于Director对字母的大小写不分,故比较字母大小写时用 charToNum()、numToChar()。 4、如果影片中有导入带Alpha通道的TIFF文件,则xtras目录中应包括Mix Services.x32文件。 5、当导入GIF文件(以Bitmap Image形式)到Director中时,发现颜色不对,可改以Animated GIF形式导入。 6、如何探测当前帧上的marker(如果当前帧有marker的话) getProp(markerList(),frame()) 7、简单按钮behavior,适合用于有大量按钮,且按钮状态只有普通和高亮两种的情况。一些书上介绍的按钮behavior功能挺强大,但每个按钮都得选择普通、高亮、按下等状态的图片,如果按钮多的话,那会累死。 按钮命名得注意,得这样命名:普通状态 aaa, 高亮状态 aaa_l 。 property pSprite,pOldSpriteMem
on beginSprite me pSprite=sprite(me.spriteNum) end
on mouseEnter me cursor 280 pOldSpriteMem=pSprite.member --将原来的按钮保存,以备恢复。 pSprite.member=member(pSprite.member.name&"_l") end
on mouseLeave me cursor 0 pSprite.member=pOldSpriteMem --恢复 end
on mouseUp me mouseUpEvent me --调用movie script,以解决不同按钮不同的mouseUp事件。 end
|
 jerrowolf
职务:普通成员
等级:1
金币:0.0
发贴:83
注册:2001/1/4 20:28:12
|
#32001/6/14 18:43:34
donlee在上个贴子中说 引用: director应用技巧
4、filmloop播放问题:在一帧内判断一个filmloop播放完毕,再继续播放下一帧。 frame script中含有以下代码,以实现"定格": on exitframe me go the frame end 再把以下behavior拖到filmloop sprite即可: on exitframe me --但用prepareframe不行?! tell sprite(me.spriteNum) if the frame = the lastframe then ploopcnt = 1 end if end tell if ploopcnt then go next --或改为其它命令 end if end
prepareframe句柄中无法跳帧,可以通过简单测试证明。
|
 zch3
职务:普通成员
等级:1
金币:0.0
发贴:25
注册:2001/4/3 16:41:10
|
#42001/6/15 14:54:18
真好!这样进步可以快一些了。
|
 春花秋月
职务:普通成员
等级:1
金币:0.0
发贴:75
注册:2001/3/30 15:30:20
|
#52001/6/18 15:44:48
很好很好,谢谢楼上的大哥
|
 老张
职务:普通成员
等级:5
金币:10.0
发贴:2796
注册:2001/5/11 12:41:55
|
#62001/6/21 11:52:10
donlee: ---------------------- 6、在projector用lingo关闭计算机(用于Windows9X),主要用于触摸屏等无人值守的情况等。 A:无论此时计算机是否有打开的程序或窗口,使用下面的lingo语句可直接关机:(仅限于projector) open "c:\windows\rundll.exe user.exe,exitwindows" 若要重新启动计算机,改为 "c:\windows\rundll.exe user.exe ,exitwindowsexec" ---------------
如果机器里有一个需要确认保存的其它应用,就会一直等下去。 有无解决办法。
|
 wkgsm
职务:普通成员
等级:1
金币:10.0
发贴:122
注册:2000/12/31 17:40:47
|
#72001/6/25 21:30:17
引用: director应用技巧
4、filmloop播放问题:在一帧内判断一个filmloop播放完毕,再继续播放下一帧。 frame script中含有以下代码,以实现"定格": on exitframe me go the frame end 再把以下behavior拖到filmloop sprite即可: on exitframe me --但用prepareframe不行?! tell sprite(me.spriteNum) if the frame = the lastframe then ploopcnt = 1 end if end tell if ploopcnt then go next --或改为其它命令 end if end
我死活不明白the frame = the lastframe的意思,请donlee讲讲好吗?
|
 wkgsm
职务:普通成员
等级:1
金币:10.0
发贴:122
注册:2000/12/31 17:40:47
|
#82001/6/25 21:39:06
donlee在上个贴子中说 引用: director应用技巧
5、对filmloop的控制。 以下behavior的功能是用于一个filmloop sprite,点击暂停,再次点击则继续。 property ppause,pframe on beginsprite me ppause=false pframe=1 end
on mouseup me ppause=not ppause if ppause then tell sprite(me.spriteNum) to pframe=the frame end if end
on exitframe me if ppause then if pframe=1 then tell sprite(me.spriteNum) to go to the lastframe else tell sprite(me.spriteNum) to go to pframe-1 end if end if end
还有mouseup和exitframe程序能逐句讲解一下吗?感激不尽。 我直接复制您的程序可以用,但变形加上timeout,想要随机播放影片循环却不行。总是控制影片循环失败。
编辑历史:[这消息被wkgsm编辑过(编辑时间2001-06-25 21:40:53)]
|
 donlee
职务:普通成员
等级:1
金币:1.0
发贴:271
注册:2000/12/8 8:52:18
|
#92001/6/28 12:57:07
简略解释: 4、 the frame = the lastframe中the frame是filmloop的当前帧编号,the lastframe是filmloop的最后一帧的编号,如果到了最后一帧,表示又播放了一个循环,结合后面的ploopcnt(循环次数的计数),可以实现完成指定的循环次数(往往我们在movie中希望filmloop播放2次或更多次),如果播完即走,那么这段程序就不用改了。
5、 在mouseup 中切换了filmloop是/否处于暂停状态,并记下filmloop的当前帧(如果切换至播放状态,这个记录动作没有用处) 在exitframe中: 这是主movie的exitframe,等filmloop接收到时已经进入了下一帧,为了实现“停”的效果,必须让它回退一帧,这就是后面语句的原因。
再次声明,tellsprite并未记入正式文档,在使用它时务必通过测试。
|
 wkgsm
职务:普通成员
等级:1
金币:10.0
发贴:122
注册:2000/12/31 17:40:47
|
#102001/6/28 23:04:37
恕在下愚钝,当点击后影片循环停止,再点击,ppause为0,mouseup和exitframe里的判断都不执行,是怎么告知影片循环又继续播放的呢?
|
 donlee
职务:普通成员
等级:1
金币:1.0
发贴:271
注册:2000/12/8 8:52:18
|
#112001/6/29 14:46:30
实际上,filmloop一直在向后运行,如果不向它传送消息,它会正常执行,所以当我们要让它暂停,要在每一帧向它发送一次回退一帧的命令。
|
 evenly
职务:普通成员
等级:1
金币:0.0
发贴:39
注册:2001/5/25 10:59:33
|
#122001/7/3 15:06:11
我改成以下的代码,鼠标放上去就停下来,鼠标拿开就继续滚动,然后简单的用一个text做的filmloop测试了一下,是有效的,但奇怪的是用在一个图片做的flimloop上就不管用了。请问这段代码有没改错了?还是因为有其他的因素影响了? property ppause,pframe on beginsprite me ppause=false pframe=1 end
on mouseenter me ppause=true if ppause then tell sprite(1) to pframe=the frame end if end
on mouseleave me ppause=false if ppause then tell sprite(1) to pframe=the frame end if end
on exitframe me if ppause then if pframe=1 then tell sprite(1) to go to the lastframe else tell sprite(1) to go to pframe-1 end if end if
|
 donlee
职务:普通成员
等级:1
金币:1.0
发贴:271
注册:2000/12/8 8:52:18
|
#132001/7/3 16:51:15
代码没问题,应该是其它方面的问题。 有一段不必要了。 on mouseleave me ppause=false --if ppause then --tell sprite(1) to pframe=the frame --end if end
|