lingo behavior
****************
Property mySprite, A, b
On BeginSprite me
mySprite = Sprite(me.SpriteNum)
A = mySprite.loch
B = 0.25
end
On Exitframe me
A = A + B
mySprite.loch = A
end
-------------------------------------
Lingo Parent Script(named "RightShover")
************************
Property mySprite, A, B
On New me, passedSpriteNum
mySprite = Sprite(passedSpriteNum)
A = mySprite.loch
B = 0.25
return me
end
On Stepframe me
A = A + B
mySprite.loch = A
end
--------------------
相同点:
1、The Behavior and Parent Script have 同样的 Property variables.
2.One has an "On Beginsprite" handler while the other has an "On New me",每个句炳 都初始化Property variables.
3.One has an "On Exitframe" handler while the other has an "On Stepframe" handler 。目的都是移动精灵).
不同点:
1.行为自动联合起精灵 ,而the Parent script is not。
In fact, a Behavior MUST BE associated with a Sprite, while the Parent script can run without any Sprite at all.
2.The Parent script returns "me" 而 the Behavior不是这样.
3.执行方式也不同。The Behavior is simply dragged onto a sprite, 而 the Parent Script must从别处得到呼叫才能执行,例如:
--------------------
--巴下面的脚本赋予精灵5
on beginsprite me
dum = new(script "RightShover", 5)
add the actorList, dum
end
----------------------------
The returned reference is then added to the actorlist, and this completes 执行. The actorlist is a 特殊的 list ,它包含字对象list. 列表中每一个 Child 接受 "Stepframe" message ,无论
播放头是 enter frame ,还是更新舞台。
向其他对象发送信息的方式的区别是
if a Behavior includes the handler "HopUp", then you can use the Lingo "SendSprite" command to 调用"hopup". If the Child object also has a "HopUp" handler,可以,例如:
m=new(script"sendmas")
m.popup
|