Fusion 2.5+
Guides & Tips+

Dropping the fruits

Dropping the fruits

For this little game, the fruits should drop from some flying object. We’ll find a suitable graphic that can fly around in the top of our screen, randomly dropping some delicious fruits.
In the graphics library “Games -> Spacecraft -> Spacecraft” there is a sprite called “Small UFO” which we can use. Drop it at the top left corner of our frame. We need this little UFO to move around in some sort of pattern or following a path. For this purpose we can use the built-in “Path Movement”.



Select the UFO, go to its movement properties and select ‘Path Movement’ for it. Then click the ‘Edit’ button to edit the UFO’s path.



This is the path movement dialog box that will pop up after you clicked ‘Edit’. With this we will draw the path we want the UFO to follow.



To begin drawing the path, you click the second button from the left. Now simply draw a curvy path at the top of the frame like if you would draw with a pencil tool in a paint program. Here is an example path.




If you test the movement now, the UFO will quickly go through the path and stop, but that is not what we want. We want it to slowly follow its path and continue in a seamless loop.
To change the speed, drag a selection box around all path nodes so they are selected. On the Path movement dialog box, you move the slider bar to a lower value than 50.
Speed 18 is a good value. We also want the movement to repeat itself when it is finished, so we click the “Loop the movement” button.
If we didn’t position the last node exactly where we started, the UFO will move slightly each time it finishes its movement. To fix this, we click the “Reposition object at end” button  to make sure it will never move away from its original position.
We should end up with a dialog box that looks like this:



Try out the game and watch our little UFO move around the screen.

Now for the fruits. Fusion has simple timing functions which we can use for the fruit creation. Let’s make some fruits drop more often than other:
Every 3rd second create an apple,
Every 5th second create a banana,
Every 7th second create some grapes.

MMF2 makes it much simpler to do these kinds of timings than other development systems where you constantly need to compare the current system time to some initial value. Here it is only necessary to tell MMF what you want to happen every three seconds and it will magically happen.

Make a new ‘Every’ condition. You can find it in the Timer object which is one of the default objects that is always included in every MMF2 application. Change the “Seconds” slider bar to the value 3.



Every action you put into this new event will happen once every three seconds. So if we put a ‘create object’ action into our ‘Every 3 seconds’ event our objects will be created every third second.
At the ‘Create new objects’ object you find in the event editor, you right click and select the ‘Create object’ action.



In this dialog you are asked which object you want to create. Simply select the apple object and click ‘OK’.



When this “Create Object” dialog opens, you can then choose the coordinates where your object should appear. If you drag around the ‘creation point’ you simply tell MMF to create it at that exact spot, but we want the apple to be created at the UFO, not at action coordinates. So simply click on the UFO object on the frame to create the apple relatively to the UFO.



You will notice that the ‘creation point’ will not overlap the UFO to begin with when you click it. If we leave it there, the apples will then be created at that position relative to the UFO. This would look odd as the apples would pop out of nowhere but close to the UFO. So drag the ‘creation point’ up to the centre of the UFO. Alternatively you can simply write the value ‘0’ into the X and Y boxes. Then it will look just the same as in the first picture. Press ‘OK’.

Test your game and watch how the UFO will drop the apples every three seconds. To sum up what we have actually done in the event editor, here is a snapshot of our events as seen in the Event List Editor.

  • (Runner) leaves the play area on the left or right

(Runner) : Stop

  • Every 03"-00

: Create (Apple) at (0,0) from (Small UFO)

By using only two lines of “code”, we have achieved to make a UFO fly around the top of the screen dropping apples that falls downwards, make a controllable animated player that is prevented from exiting the screen at the left and right. Simple isn’t it?

In the event editor, create a few more events that creates the fruits, but change the time between each fruit drop.

Spread the word!

You can share this document using the following buttons.

Submit your own User Tip