Chocobreak Tutorial - Step 6
Step 6: The player
Inspect the "ChocoBreak Tutorial" library, in the bottom of your screen, and find the object named "Player". Drag and drop it in the bottom of the play area, just in the middle, between the two vertical sugar objects.
Just as for the ball, we have to define the movement property of this object. Click on it, to make the properties appear in the property toolbar. As for the ball, locate the "Movement" tab, and click on it.
Open the "Type" combo box. We want out player to be controlled by the mouse. Select the "Mouse controlled" option in the list.
Now click on the "Edit movement" button. A flashing zone can be seen on the screen. Using the handles of this zone, restrict the movement of the object by dragging the small black boxes until the zone looks like a thin rectangle, from one of the sugar objects to the other, like so:
Do not forget that you can test the movement at any time by clicking on the "Try movement" button. Once the movement satisfies you, click on the OK button to come back to the frame editor.
If you test your game right now, you will see that the player actually moves on the screen, but does not affect the ball at all : the reason is obvious, we have yet to define an event to do so in the Event editor.
What we want to test is : "When the BallGolden object collides with the Player object, bounce BallObject".
Note: Since the movement of the "Player" object is now controlled by the mouse, the mouse pointer will vanish when you launch your game. For now, the only way to close your game in that case, is to press at the keys Alternate-F4. In the next chapter, you will discover that you can define a keypress, like the Escape key, as a way to end your game.
So let's go! We are ready to make our game playable now! Click on the Event editor button in the tool bar, to open the editor. You can notice that a new icon, the "Player" object has been added to the top bar. You should now be able to enter this event by yourself. Please try to do so, and if you do not succeed, then read the following text that will guide you through the task.
Click on the New condition line to open the New condition dialog box, here too, you will see the new "Player" object (do not confuse it with the "Player 1" object!). Right click on the "BallGolden" object to open the Condition menu. In the menu choose the option "Collision" / "Another object". In the next dialog, double click on the "Player" object. A new line is added to the list of events in the event editor.
Now locate the ball object in the top bar, and move your mouse down until you reach the empty square in front of the new condition we have just entered. Then, click with the right mouse button to open the actions menu. Choose the option "Bounce". A new checkmark will appear in the editor : you new action is defined!
Now click on the "Run Frame" icon in the tool bar : you should be able to play your game. The ball bounces off of the player!
Spread the word!
You can share this document using the following buttons.