Chapter V

Learning to Walk

  1. Moving an Emoji

    Now that we have our characters, the next step is making them do something.

    Add this code below the line containing ActionWait:

    newScene.addAction(ActionMove(1000, emoji1, Vector2(100, 400)))
    

    arrow_down

    It moved!

    You should now see the laughing Emoji downwards, to the position (100, 400).

    Let’s break down how we construct ActionMove:

    ActionMove(duration, emoji, position)
    

    The Action tells the Scene to move an Emoji from its current position to a new position in duration seconds. Try changing the numbers and see what happens!

  2. Multiple Movements

    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:

    Answer

  3. Scaling

    Another Action we can use is ActionScale.

    Here’s how you can construct it. Try using it and seeing what happens:

    ActionScale(duration, emoji, scale)
    

    i.e:

    ActionScale(500, emoji1, 2)
    

    Will scale emoji1 by a factor of 2 in 500 milliseconds (half a second).