08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

e the way you left it the last time. Checking the box labeled Persistent will do exactly that.<br />

The room status will be remembered and when you return to it later, it will be exactly the<br />

same as you left it. Only when you restart the game will the room be reset. Actually, there is<br />

one exception to this. If you marked certain objects as being persistent, instances of this<br />

object will not stay in the room but move to the next room.<br />

Secondly, there is a button labeled Creation code. Here you can type in a piece of code in<br />

GML (see later) that is executed when the room is created. This is useful to fill in certain<br />

variables for the room, create certain instances, etc. It is important to understand what<br />

exactly happens when you move to a particular room in the game.<br />

• First, in the current room (if any) all instances get a room-end event. Next the non-<br />

persistent instances are removed (no destroy event is generated!).<br />

• Next, for the new room the persistent instances from the previous room are added.<br />

• All new instances are created and their creation events are executed (if the room is<br />

not persistent or has not been visited before).<br />

• When this is the first room, for all instances the game-start event is generated.<br />

• Now the room creation code is executed.<br />

• Finally, all instances get a room-start event.<br />

So, for example, the room-start events can use variables set by the creation code for the<br />

room and in the creation code you can refer to the instances (both new ones and persistent<br />

ones) in the room.<br />

There is one further option. In the pop-up menu when you right click on an instance <strong>with</strong> the<br />

key you can now indicate some creation code for the specific instance. This code is<br />

executed when the room is started, just before the creation event of the instance is executed.<br />

This is very useful to e.g. set certain parameters that are specific to the instance.<br />

Adding tiles<br />

You can also create so-called tiled background. The reason for this is as follows: In many<br />

games you will want to have nice looking backgrounds. For example, in a maze game, the<br />

walls of the maze should nicely match up, and in platform games you like to see beautifully<br />

drawn platforms, trees, etc. You can do this in <strong>Game</strong> <strong>Maker</strong> by defining many different objects<br />

and composing your rooms from these objects. The problem though is that this takes a lot of<br />

work, uses large amounts of resources, and makes the games run slowly because of the many

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!