Tutorial
Page 7 of 15
The Create Event
Appart from the object details, the rest of the Object Properties window is taken up by two sub-windows: one for adding events, and one for adding actions to those events. With the buttons below the
Events window you can add events, delete events or change events, of which there are a large number of different ones you can use.
Next to the events there is an empty list of actions that must be performed for the selected event (if any), and at the right of this list that are a number of tabbed pages with little icons. These icons represent the
different actions and in total there are close to 100 different actions you can choose from. If you hold your mouse above one of the icons a short description of the corresponding action is given in a tooltip. You can
drag actions from the tabbed pages at the right to the action list to make them happen when the event occurs. This is called the Drag and Drop system of programming (D'n'D for short).
So, to get things started with programming our game, we are now going to define what should happen when an instance of the clown object is first created. In this case we want the clown to start moving in an
arbitrary direction at a fixed speed so proceed with the following:
- Press the Add Event button. The Event Selector, as shown below, will appear.
- Click on the Create Event button. The Create event is now added to the list of events, and it is automatically selected (you should see it highlighted in the IDE).
- Next you need to include a Move Fixed action in the list of actions. To this end, open the Move tab and then press and hold the mouse on the action image with the eight green arrows in
the page at the right, drag it to the empty actions list, and release the mouse to drop it into the action list for the event. An action window will now open asking for information about the action.
- In the action window for the Move Fixed action you can indicate in which direction the instance should start moving. Select all eight directions (not the middle one which corresponds to no
motion), and note that the selected directions turn red. When multiple directions are selected one is chosen at random when the event is run. Also set the Speed to 4. The "speed" of an instance is
calculated as "pixels per step", so 4 means that the instance will move 4 pixels in the given direction every game step.
- Press OK to indicate that we are ready with this action.
You have now specified behaviour that must be executed when an instance of the clown object is created, by adding the event, including an action, and setting the action properties. The object properties window for
the clown object should now look like this:
© Copyright YoYo Games Ltd. 2014 All Rights Reserved