GAME MAKER TUTORIAL
MINI TUTORIAL 06 – ANIMATION CONTROL

separator-blank.png

DESCRIPTION

·        In this mini tutorial, you will learn how to control GIF animations by changing the built-in image_speed variable.  You will also see how to create buttons.

RESOURCES                                                           .

·        Click here.

STEPS

GameMaker Version 1.4.1749

 

1 – Creating our sprites

·        Create 7 sprites and load one of the button images in each one.

o   Name the sprites after the text on the button

·        Create a sprite with the dragonAnimation.gif image.

o   Name: spr_dragon

 

2 – Create 8 objects – one for each sprite above.

·        The dragon object needs to be named: obj_dragon

 

3 – PLAY button

·        In the Play button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 1

 

4 – PAUSE button

·        In the Pause button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 0

 

 

5 – BACKWARDS button

·        In the Backwards button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: -1

 

 

6 – FAST button

·        In the Fast button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 2

 

7 – SLOW button

·        In the Slow button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 0.5

Explanation:  Notice that the five buttons we've done so far have very very similar actions in them.  The only difference is the value of the dragon object's image_speed.  The reason that each of the Set Variable actions specify "obj_dragon.image_speed" instead of just "image_speed" is to change the value of "image_speed" inside the obj_dragon object.

 

8 – FIRST button

·        In the First button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_index

o   Value: 0

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 0

 

9 – LAST button

·        In the Last button object, add a Mouse Event > Left Click

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_index

o   Value: 72                        (the GIF's last frame is #72)

·        Inside, add a Set Variable action

o   Variable: obj_dragon.image_speed

o   Value: 0

10 – Adding objects to our room

·        Create a room.  Size it as you wish.

·        Add one of each of the button objects.  Place them where you'd like.

·        Add one obj_dragon.

Save and test!

 

SOURCE

  • Straight from Mr. Campeau's brain.  J

separator-campeau.png