Using Flags in Clickteam Fusion 2.5

What is a flag in Clickteam Fusion 2.5?

Flags in Clickteam Fusion 2.5 are very useful to get to use throughout your game design and development process. A flag basically is a Boolean. A flag can either be true or false. This can be represented in many different ways such as true or false, 0 or 1, on of off. Either representation you follow it virtually means the same thing, is it true or false. That is how Booleans work, that’s how flags work in Clickteam Fusion 2.5 and flags are very useful for storing whether something is on/off, true/false or 0/1 and in this free tutorial we will cover how you can use flags in literally just 2-3 events in Clickteam Fusion 2.5.



How can we use flags?

You can use flags in many different scenarios. Let’s look at a hypothetical scenario; you could have a set of “lights” in your game and when your player clicks on a light, you want that light to show and all the others turn off. In this free Clickteam Tutorial we will go over this scenario.

Setting up the Playarea

Open up Clickteam Fusion 2.5 and create an Active object. We can use the default diamond shape active for this tutorial. We need to copy the first frame and make a second frame, we then need to paint the first one red and the second one green, like below.

The default Active object Fusion 2.5

Once you have done this, click on the ‘direction options‘ tab and set the animation speed to 0. Click Ok.

Now, place 5 of these lights next to each other like so…

Clickteam Fusion 2.5 Active Object

Select one of the objects and locate its properties, click on the ‘Values‘ tab and create a new alterable value and call it ‘obj_flag‘.

Now let’s go into the Event Editor (Ctrl+E).

Using Flags in the Event Editor

By default each active object has 32 of its own flags, numbered from 0 to 31, also by default, all these flags are set to ‘off‘ until you either turn it on or turn it back to off.

Let’s create our first event. Click on the new condition for a new event, hover over the mouse/keyboard icon, right-click and select The Mouse > User clicks on an object. When the dialog appears, select our active object. Now in that event line, hover over to the active object column, right-click and select Flags > Toggle. When the dialog appears, type 0 and click Ok. We will use Flag 0.

Now, internally, every time we click on one of the active objects, it will toggle it’s flag on or off. So the first click will turn it on, the second click will turn it off. We need to show this visually.

Let’s create a new event underneath, click add new condition, hover over the active object, right-click and select Alterable Values > Flags > Is a flag on? and when the dialog appears, type 0. Click Ok. Now in this event line, hover over the active object column, right-click and select Animation > Change > Animation Frame and when the dialog appears type 1.

Repeat the above event in a new event but this time select Alterable Values > Flags > Is a flag off? And change the animation frame of the active object to 0.

Now run your application, you should be able to click on an object and toggle whether the Flag 0 is on or off and you can see this based on what frame it is showing.

Refining the flag process

It’s important to know here that, even though we are visually handling Flags as True or False internally, Clickteam Fusion 2.5 is handling them as 0 or 1. 0 for off and 1 for on.

Now, because we have two frames inside of our object (Red/Green) we can use the value of the Flag (o for off and 1 for on) to specify in one event which animation frame to show.

Delete or inactivate those last two events we just did and create a new event. Right-Click on the ‘Special Conditions‘ icon and select ‘Always’. Now in that event line hover over to the active object, right-click and select Animation > Change > Animation Frame. We don’t need to specify 0 or 1 here because we can let the value of the flag do it. So in the expression dialog, right-click on the active object and select Values > Value of one of internal flags and when it says <Enter Value Here> in the expression, just type 0, as it is Flag 0 we want the status of. Click Ok and run your application and test it.

We can see here that we don’t have to test if the flag is on or off using two different events if we don’t want to, because we are dealing with 0 for off and 1 for on, we can just use this value to force the frame shown for the object.



You can see now just how useful Flags can be in your developments with Clickteam Fusion 2.5. They are very useful if you need to ‘toggle’ stuff whilst at the same time comparing to see if a flag is true or false, o or 1, on or off. I think you get the gist.

You can download the completed MFA from here.

Flags in Clickteam Fusion 2.5

I hope you enjoyed this Free Clickteam Tutorial from the ClickFusion Academy. If this was useful to you, why not consider becoming a Lifetime Student of ours and enrol in our Clickteam Fusion 2.5 Lifetime Course. You will gain access to a full curriculum where you can learn at your own pace with expert tuition, advice and guidance. There is plenty of written lectures, video lectures, tutorials and examples for you to read, watch, download and experiment with, as well as access to our private online forum where you can ask questions from the teachers and other students and work on your own material with guidance and support. Click here to enrol today.


Join the Academy Today


Learn Clickteam Fusion 2.5 taught by experts
Access Exclusive Downloads, Examples and Open-Source Projects
Active Supportive Community Forums and post-it boards
Live Weekly (and daily) Video Streams
Click Fusion Logo