当前位置:文档之家› 常见Lingo指令介绍

常见Lingo指令介绍

常见Lingo指令介绍一、控制Sprite的常见指令1.指令名称:sprite member指令语法:the member of sprite指令说明:sprite所代表的cast member。

例:精灵替换set the member of sprite 1 to "yuan"可改为:Sprite(1).member=”yuan”点句表示法:ObjectName.[Property|function|Chunk that you want to specity]2.指令名称:sprite memberNum指令语法:the memberNum of sprite指令说明:sprite所代表的cast member所在的位置。

例:循环播放on exitFrame meif sprite (1). memberNum =10 thensprite (1). memberNum = 1elsesprite (1) .memberNum=sprite(1).memberNum+1end ifgo to the frameend3.旋转、倾斜、翻转精灵指令说明:这些变换可以应用于位图、文本、矢量图形、GIF及Flash,但不能用于域,以及工具面板上的椭圆和矩形。

(1)旋转:正值代表顺时针,负值代表逆时针sprite(1).rotation=30set the rotation of sprite 1 to 30例:指针调节sprite(1).rotation=sprite(1).rotation+5(2)倾斜:正值向右倾斜,负值向左倾斜,正常状态为0sprite(1).skew=10set the skew of sprite 1 to 10例:图形变形sprite(1).skew=sprite(1).skew+10(3)翻转:左右(水平)翻转flipH,上下(垂直)翻转flipV,设置值为TRUE或FALSE (1或0)sprite(1).flipH=TUREsprite(1).flipV=1例:翻转与恢复指令说明:相当于sprite在stage上的透明度,值可从0到100,数值越小透明度越高。

Sprite(1).blend=50Set the blend of sprite 1 to 50例:图像渐淡sprite(1).blend=505.指令名称:loc、locH、locV指令说明:the loc of sprite:sprite当前的位置,相当于point(the loch, the locV)the locH of sprite:水平位置the locV of sprite:垂直位置sprite(1).loc=point(320,240)------pointsprite(1).locH=320――数值sprite(1).locV=240――数值例:设置精灵位置sprite(1).loc=point(320,240)6.locZ指令说明:sprite目前在Z轴上的高度。

Channels之间存在高低与前后的关系,channel小的sprite位于下层,channel大的sprite位于上层。

例:点击相应图片移到最上层。

on startMovieglobal highestCardhighestCard=5endon mouseUpglobal highestCardhighestCard=highestCard+1sprite(the clickOn).locZ=highestCardend7.Top、bottom、Left、right指令说明:环绕sprite长方形的上下左右坐标。

on mouseUp meput sprite(1).topput sprite(1).bottomput sprite(1).leftput sprite(1).rightend用massage窗口查看。

例:文字上下或左右反复运动。

Put Sprite(1).rect例:匹配题intersects的应用指令说明:在stage上留下残影sprite(1).trails=true9.updatestage更新画面,常用于显示连续的动作例:拖尾移动on mouseUp mesprite(1).trails=truerepeat with x=1 to 100sprite(1).locH=sprite(1).locH+2updatestageend repeatend10.foreColor、backColor控制演员前景色、背景色的属性。

注意:这个属性主要用于用“tools palette”工具画出的Shape(向量)图形例:鼠标点击循环改变精灵的前景(背景)色on mouseUp mesprite(1).foreColor=sprite(1).foreColor-1end11.constraint指令说明:将某一可移动的sprite的中心点的活动范围限制在另一个sprite的四周边框内。

on startMoviesprite(1).constraint=2-- 2代表sprite(2)12.visible指令说明:sprite在stage上可见或隐藏。

一个隐藏的sprite仍具有位置、尺寸等各种属性,只是视觉上看不见而已。

Sprite(1).visible=false13.puppetSprite判断某一sprite是否处于puppet状态,是时,其属性与行为将由Lingo控制,否则依据score window中的设置。

例:将sprite 1设置为puppet状态。

On prepateMoviepuppetSprite 1, trueend14.quad控制sprite的四个顶点,用数组的方式来存放四个点的坐标值,依序分别为左上、右上、右下、左下,改变四个点的坐标,可以改变sprite的图框形状on mouseUp meput sprite(1).quadput sprite(1).quad[1]put sprite(1).quad[2]put sprite(1).quad[3]put sprite(1).quad[4]endsprite(1).quad=[point(9.0000,10.0000), point(309.0000, 10.0000), point(309.0000, 210.0000), point(9.0000, 210.0000)]sprite(1).quad[1]= point(9.0000,10.0000)数组在Lingo里就叫做列表,列表可以存储一系列连续的数据,如果数据具有相似性、规律性,需要放到一起就可以使用列表来表示。

二、鼠标(Mouse)控制的常见指令1.指令名称:clickOn指令语法:the clickOn指令说明:判断鼠标最近一次点选过的sprite。

返回最近一次单击精灵通道的通道号,如果在舞台上单击则返回值为0。

注意:只有附带程序(写在cast或sprite里面均可)的sprite才会被判断,即使这个程序毫无作用也无妨,例如:on mouseDown--end例:(1)beep次数控制on mouseUprepeat with x=1 to the clickOnbeepend repeatend(2)设置不带程序sprite(3)message窗口观察clickonon mouseDownput the clickonend2.指令名称:mouseH、mouseV指令语法:the mouseH、the mouseV指令说明:当前鼠标点(cursor)的水平位置(the mouseH)与垂直位置(the mouseV)。

例:判断鼠标接近spriteon exitFrame medH=the mouseH-sprite(1).locHdV=the mouseV-sprite(1).locVif dH*dH+dV*dV<7*7 thenbeepend ifend——鼠标判断在附近变为手的形状。

3.mouseLocpoint(the mouseH, the mouseV)例:鼠标设置sprite的位置综合练习:拖动四角变形图片。

on mousedowntemp=sprite(1).quadrepeat while the mousedownsprite(the clickon).loc=the mouseloctemp[the clickon-1]=the mouselocsprite(1).quad=tempupdatestageend repeatend4.rollOver指令语法:the rollover指令说明:rollOver(whichSprite)的作用是判别光标目前是否位于the sprite 的长方形区域内,是则rollOver(whichSprite)为1,否则为0。

The rollover所代表的是光标下的sprite channel。

这个指令通常用在frame script里面。

例:鼠标略过,发出不同的音乐。

on exitFrame mecase (the rollover) of1: puppetSound "piano"2: puppetsound"干杯吧朋友"3: puppetSound"我是一只小小鸟"end caseend5.mouseEnter、mouseLeave语法指令:on mouseEnter、on mouseLeave指令说明:mouseEnter:判断鼠标是否刚刚进入某个sprite区域;mouseLeave:判断鼠标是否离开这个区域。

如果这个sprite是bitmap图形,且其ink effect是matte,则他的区域为图形本身,否则为环绕其的长方形。

他们与rollover()的区别:(1)mouseEnter与mouseLeave通常在cast script or sprite script,而rollOver ()却用在frame script;(2)mouseEnter与mouseLeave只被执行一次,而rollOver()常常会连续被执行。

例一:将上例完善,鼠标放到相应文字上改变颜色和鼠标形状on mouseEntermember(1).forecolor=56cursor(280)end mouseEnteron mouseLeavemember(1).forecolor=255cursor(-1)end mouseLeave例二:鼠标超时警告on mouseEnterstarttimerendon mouseLeaveif the timer>2*60 thenalert "Too Slow!"end ifendtick6.mouseWithin指令语法:on mouseWithin指令说明:判断鼠标点是否位于某个sprite区域之内。

相关主题