SHOW:
|
|
- or go back to the newest paste.
1 | local file = ... or "Square.png" | |
2 | ||
3 | return LoadActor( file )..{ | |
4 | OnCommand=function(self) | |
5 | self:playcommand("ResetPosition") | |
6 | end, | |
7 | ResetPositionCommand=function(self) | |
8 | - | |
8 | + | |
9 | -- reset the rotation ammount to 0 | |
10 | -- reset x to be newly randomized | |
11 | - | -- and reset y to be offscreen below _screen.h |
11 | + | -- and reset y to be offscreen below _screen.h |
12 | self:rotationz(0) | |
13 | :x( _screen.w - math.random(0, _screen.w) ) | |
14 | :y( _screen.h + self:GetHeight() ) | |
15 | :diffuse(color("#5a5a5a")) | |
16 | :zoom(0.8) | |
17 | :queuecommand("Animate") | |
18 | end, | |
19 | AnimateCommand=function(self) | |
20 | - | |
20 | + | |
21 | -- tween duraiton of 2 seconds | |
22 | self:linear(2) | |
23 | - | |
23 | + | |
24 | :y( -self:GetHeight() ) | |
25 | -- rotate one full revolution on the z-axis | |
26 | - | |
26 | + | |
27 | -- and, finally, reset the position so we can do this again | |
28 | :queuecommand("ResetPosition") | |
29 | - | |
29 | + | |
30 | } |