Chapter IV

Sculpting an Emoji

  1. Adding an Emoji

    If we want an interesting story, we need to have some characters.

    These characters are going to be Emojis.

    Add this code below newScene.setBackgroundColor(COL_BLUE) and above game.addScene(newScene):

    emoji1 = Emoji('laughing')

    Your code should now look like this:

    Code view

    This will add a laughing emoji to the Scene, but executing the code will not show anything. This is because there aren’t any Actions included in the Scene.

  2. Moving Your Emoji

    A Scene contains a series of Actions which are executed one-after-another. There are a few different Actions we’ll go over today, the first of which is ActionWait.

    Let’s add an ActionWait to the Scene so we can see what’s happening (below newScene.addEmoji(emoji1)).



    Laughing emoji

    ActionWait causes the Scene to be paused for a bit.

    Want to make the wait longer? Adjust the 1000 in ActionWait(1000) to another amount.

    The 1000 represents 1000 milliseconds, which is equivalent to 1 second. So, for example, if you wanted 1.5 seconds you could change 1000 to 1500.

  3. Emoji Position

    Each Emoji has their own position, (x,y) - how far along the x-axis it is, and how far along the y-axis it is.

    When you create an Emoji, it starts at (0,0) by default. We can change this by giving our own position:

    emoji1 = Emoji('laughing', Vector2(100, 200))


    Moved laughing emoji

    The Emoji should now start at the position (100, 200)

    The screen’s total size is (480,480). This will be useful when moving Emojis!

  4. Multiple Emojis

    Now we understand how to add one Emoji to our Scene, it’s easy to add more.

    Add this below newScene.addEmoji(emoji1):

    emoji2 = Emoji('shocked', Vector2(300, 200))


    Two emoji!

    You should now see a shocked emoji in the Scene as well.

    There are a few different emojis included for you to use, including:

    • 'laughing'
    • 'shocked'
    • 'angry'

    There’s a reference page here with the full list

    Nothing working? Your code should look like this by now:

    Current code