Chocobreak Tutorial - Step 5
Step 5: Making the ball bounce
We have just defined the ball movement of the ball object : you can run the frame again, by clicking on the "Run Frame" button, as before. You should see the ball move and vanish out of the playfield. It works, but we need the ball to stick around for the game! What is the problem? We can see that the ball does not bounce on the "sugar" object as it should. We have to instruct Clickteam Fusion 2.5 to make the ball bounce off of objects. To do that, we will now discover the Event editor.
Locate the "Event editor" button in the tool bar, and click on it.
The display should look like this:
Let's think about what we want to achieve. We want the ball to bounce when it collides with the vertical and horizontal bars. If we use the name of the objects as we saw them in the frame editor, the sentence becomes : "when the object BallGolden collides with object SugarVertical1, then the Object BallGolden should bounce".
This sentence is in two parts, the first part can be called the condition. A condition is simply a way to determine when something has happened. Here, our condition is "when the object BallGolden collides with object SugarVertical1". The second part is the action to take place when the condition occurs. We call that the action. In life, you see conditions and actions all the time. For instance, if the condition was, "Is it my Birthday?" Then, when your Birthday came, the action might be to "Celebrate!" Here our action is "Object BallGolden bounce".
An identical condition/action sentence could be constructed for the other objects SugarVertical2 and SugarHorizontal.
Now, let's create our conditions and actions in Clickteam Fusion 2.5. With you mouse, click on the "New condition" line on the screen:
The New Condition dialog box opens immediately.
The content of this dialog box is simple : it shows the objects we are using in the game and some standard objects that are always available. Among the objects you see displayed, you will find the objects that you have already dropped on the frame under the frame editor, and some new objects that we will talk more about later. Right now, we will concentrate on the BallGolden object, our game ball.
Now click with the right mouse button on the ball : this opens a new popup menu, the conditions menu.
Explore this menu, and you will discover many entries : this menu contains all the available conditions for the object BallGolden. For example, you can test the position of the object on the screen, its direction, count the number of balls on the screen, etc. Remember that we wanted to test the collision of our ball with the SugarVertical1 object. So, open the "Collisions" submenu, and select the option "Another object".
It immediately opens another dialog box:
We test the collision of the object BallGolden with another object : Clickteam Fusion 2.5 is asking us to choose which object to detect. If you remember our sentence, we want to test the SugarVertical1 object : double click on the object.
The dialog box should immediately vanish, and the event editor should now display a new event line:
We have just defined a new condition! As you can see above, that condition will be true every time BallGolden collides with SugarVertical1. We now have to enter the action that will happen when this condition is met. Carefully inspect the top bar of the event editor : it contains the objects we have seen in the condition dialog box. Some new objects, and the objects we have dropped in the game.
OK, what we want to do, is to have the BallGolden object bounce. This is our desired action. The first thing to do, is to locate the BallGolden object in the bar, then move the mouse in the empty square under the BallGolden object, and click with the right mouse button.
This instantly opens the actions menu of the object BallGolden.
Inspect this menu : it contains a list of possible actions for the object : we can stop it, start it, set its speed, change its position, hide it, show it etc. All these actions are at our disposal when creating a game. But, we want the ball to bounce, remember? Locate the "Bounce" option in the "Movement" submenu, and select this option. The menu will disappear, and now the empty square is filled with a check mark, indicating that an action is now defined. Move your mouse over the checkmark and a popup window will appear stating the action.
You have defined your first event : one condition plus one action. Bravo!
We still need to define the same type of event for when the ball collides with the SugarHorizontal object, and the SugarVertical2 object. Let's do that.
Click on the "New condition" line, and open the "New condition" dialog box. Locate the BallGolden object, and right click on it to open the conditions menu. In this menu locate the "Collision" / "Another object" entry and select it. In the next dialog, select the SugarHorizontal object (which is the one we want to test).
Press OK. A new line appears in the event editor.
Now for the action : locate the BallGolden object in the top bar, and get your mouse down in the empty square located at the same level than the new condition we have just entered.
Right click on the square to open the action menu, and select the "Bounce" action. You have just defined your second event! Its easy, isn't it?
Now for the third object, do exactly as before, but instead of choosing SugarHorizontal, choose SugarVertical2. With a little practice, you will find that creating events that have conditions and actions is intuitive. Most of your creation in Clickteam Fusion 2.5 will consist of simple steps like this. Once all the events are defined, the event editor should look like this:
You now can launch the game : When runs, you will see the ball magically bounce on the objects. It will eventually disappear in the bottom of the screen.
Does this give you a hint of the next task we want accomplish in creating this game?
Spread the word!
You can share this document using the following buttons.