Tutorial

Page 7 of 10

Changing Skins

Of all the features that skeletal animation brings to GameMaker: Studio, the ability to change skins is arguably the most powerful. With skins you can create a single animation and then have a multitude of instances in your game use it, but each one with it's own skin to give a distinct "look" to the final sprite. For example, you can have a base "walk" animation and assign it to a single NPC character object, then have it choose a random skin at the start of the game to give variety to a single object.

In our tutorial game we actually have four different skins to choose from, and to show you the basics of how it works, we are simply going to have our player object change when a key is pressed.

Open the object "oPlayer" now and in the Create Event add the following:



Here we are creating an array of skin "IDs" to use for changing skins. In your own games you will obviously do this in different ways, but as we just want to skip through the different options in this tutorial, an array is ideal. We also set a variable to hold the number of the current skin array.

We need to add another Key Press Event event to our object, so add that now for the key "Q". In this event drag a code action and place the following code:



Here we are incrementing our controller variable and then using that to set the skin that should be drawn currently. Run the game now and give it a go...






© Copyright YoYo Games Ltd. 2014 All Rights Reserved