Learning to Walk
Moving an Emoji
Now that we have our characters, the next step is making them do something.
Add this code below the line containing
newScene.addAction(ActionMove(1000, emoji1, Vector2(100, 400)))
You should now see the laughing Emoji downwards, to the position
Let’s break down how we construct
ActionMove(duration, emoji, position)
The Action tells the Scene to move an
Emojifrom its current position to a new
durationseconds. Try changing the numbers and see what happens!
Let’s make the shocked Emoji move to the position
(200, 300)after the laughing one does, in 2 seconds.
To do this, add another
newScene.addAction(...)line below the one you just added.
Try to figure out how to do this yourself!
Still stuck? Hover for the answer:
Another Action we can use is
Here’s how you can construct it. Try using it and seeing what happens:
ActionScale(duration, emoji, scale)
ActionScale(500, emoji1, 2)
Will scale emoji1 by a factor of 2 in 500 milliseconds (half a second).