Basic Object Scoping in Clickteam Fusion 2.5

Basic Object Scoping in Clickteam Fusion 2.5

Object scoping in Clickteam Fusion 2.5 enables you to include only various instances of an object to apply actions to. This is useful if you have say 10 copies of the same object on the screen but you only want to select 1 or more where certain conditions apply (ie: object is in a certain area).

As a hypothetical scenario, let’s say for instance we have 10 balls all which have different numbers on (but the same object) on the screen bouncing around, however we only want to highlight balls with a particular number, say 3, we can use some basic object scoping in Clickteam Fusion 2.5 events to show only those balls displaying the number 3.

In this free Clickteam Tutorial that is exactly what we will concentrate on.

In this lesson you will learn how to;

  • Create a Ball Active Object with numbers and place it in the playarea
  • Store a global value and use it to compare which number to show
  • Highlight only those balls that match the number we search for

Setting up the tutorial playarea

Let’s go ahead and open up Clickteam Fusion 2.5 and start a new application. Once you have done this, jump into the first frame. Insert an Active Object (Insert > New Object) and select Active.

Active object in Clickteam Fusion 2.5

Once you have dropped this into the playarea, double-click it to edit it. In the first frame, create a simple ball like so…

Create a ball in Clickteam Fusion 2.5

Once you have created your ball, click on the ‘text tool’ in the art editor toolbar on the left (the A icon) and select the white colour now type in 1 over the ball like so…

Active ball Fusion 2.5

Now repeat the same step above and add another 2 balls with 2 and 3 labelled on them, you can choose your own colours. It should look like this eventually… If you don’t want to do this, you can download the Template MFA for this tutorial here.

Different coloured balls in Fusion 2.5

Once this is complete, click Ok. Now, click on the Active object and locate its properties in the property pane on the left of the window. Rename it to Ball.

Active object name properties

Once done, click on your Application in Fusion 2.5 to get the application properties up. Let’s create a new global value, call it select. We will use this to define what ball we want to show.

Global Values in Clickteam Fusion 2.5

Now that we have setup the app and playarea for this tutorial, before we jump into the Event Editor, place some more of the balls in the playarea. You can dot them around as you please and insert as many as you wish. Once you have done this, click on one of the balls and click on its movement tab in the properties. Give it a bouncing ball movement and turn its speed down to 6.

2016-12-08-12_59_17-clickteam-fusion-developer-2-5-basicobjectscope-template-frame-1 2016-12-08-12_59_49-clickteam-fusion-developer-2-5-basicobjectscope-template-frame-1_

As you can see from my playarea below, I have dotted them around the playarea randomly. You can do the same…

Clickteam Fusion 2.5 Object Scoping Tutorial

Our tutorial playarea is now setup and complete.

Clickteam Fusion 2.5 Event Editor

Let’s jump over to the Clickteam Fusion 2.5 Event Editor to make some magic happen regarding our object scoping when the user is running the app. The first thing we need to do is control the movement of those objects, when they leave the screen, we won’t be able to see them so we need to contain them to the playarea window.

To create your first event, click New Condition, hover over the Ball icon, right-click and select Position > Test Position of Ball and select all the arrows pointing towards the outside of the window (the ones inside). Click Ok.

Bouncing Ball Position

Once you have done this the event should read: “Ball leaves the playarea”. In this event line, hover over to the Ball object, right-click and select Movement > Bounce. Now create a new event below that one. In the new condition dialog, right-click on the ball object and select Collisions > Another Object. When the dialog appears, select the ball object again. When this event is created, hover over the ball object, right-click and selected Movement > Bounce. What this event does is bounce the balls when they collide with each other. Your event editor should currently look like this…

Clickteam Event Editor

You can now run your application by pressing F8 on your keyboard or by going to the menu Run > Application. The balls you put in the playarea should now be bouncing around the screen and into each other at a nice, steady pace. If this works, let’s proceed to the next step.

Animations in Clickteam Fusion 2.5

When you create animations in active objects in Clickteam Fusion 2.5, it uses a 0-based index. To highlight this more let me explain a bit more clearer. When you edit an active objects animation in the frame editor, you see Frame 1, Frame 2, Frame 3 etc. but internally, Clickteam Fusion 2.5 handles these as Frame 0, Frame 1, Frame 2. So whenever we reference Frame 1 in the Event Editor we have to actually reference Frame 0. I hope this makes sense.

So, we are going to assign a random frame to display for each ball at the Start of the Frame. This will allow our balls to display random frames, which in turn will mean they display different numbers 1, 2 or 3 like we drew earlier. So let’s go ahead and create a new event. In the new condition dialog, hover over the Storyboard Object, right-click and select Start of Frame.

Once this event is inserted, hover over to the ball object, right-click and select Animation > Change > Animation Frame. When the dialog appears asking us which frame to change to, we need to type in random(4). This will force each ball to display a random animation frame between 0 and 3. Once you have inserted this event, go ahead and run your application. You should see each ball displays a random number.

Now, we need to detect when we press 1, 2 or 3 on the keyboard and store that value in that Global Value we created earlier so let’s create those events.

Insert a new event (new condition) and hover over the Mouse/Keyboard icon, right-click and select The Keyboard > Upon pressing a key.

The Keyboard upon pressing a key

When the dialog appears for you to press a key, press the number 1.

Now in this event line, hover over the first column (Special Conditions Icon), right-click and select Global Values > Set. Ensure the ‘select’ value is chosen in the list. In the expression dialog, write the number 1. Like so…

Detecting a keypress in Fusion 2.5

Click Ok. Repeat this step for the user pressing 2 and 3, respectively.

Your Event Editor should now look something like this…

Clickteam Fusion Event Editor Tutorial

Once you have done this, you can test if it works by running the application and pressing numbers 1, 2 and 3 on your keyboard. If you open up Global Values in the Debugger, you should see the select value changing in relation to whichever key you pressed.

Clickteam Fusion 2.5 Debugger

Object Scoping in the Event Editor

Okay, now all that is handled, all that is left to do is scope our objects in Clickteam Fusion 2.5. Jump back into the Event Editor. Insert a new event (new condition). Right-click on the ball object and select

Changing animation frame at runtime

When the expression dialog appears, type in select – 1. Remember, we have to put -1 because in the playarea the frame is 1 but internally it is classed as 0, so if select is 1, we want to display frame 0, so we put -1 to make select become (1-1=0). When the event is inserted, hover over to the ball object on that event line, right-click and select Visibility > Make Object Reappear.

Do another event below this one, same event again but this time in the comparison method of the expression dialog, change it to different instead of equal. Again type in select – 1. When the event is inserted, hover over the ball object, right-click and select Visibility > Make object Invisible.

Our tutorial should now be complete. Run your application and press 1, 2 or 3 on your keyboard. As the number changes, it will only show the balls that are displaying that number and hide the balls that are displaying a different number.

Basic Object Scoping in Fusion 2.5

This is a good introduction into basic object scoping in Clickteam Fusion 2.5. There are many more different scenarios you can scope and there are far greater depths you can scope to in Clickteam Fusion 2.5 and we pretty much cover a lot of those scenarios in our extensive Lifetime Course. If you feel this tutorial was beneficial for you, please feel free to share it online and on Social Media. If you want to learn more about Clickteam Fusion 2.5 check out our other free tutorials on our website or consider becoming a Lifetime Student and gaining access to our online course for Clickteam Fusion 2.5 which covers almost every topic you could imagine with a nice, steady curriculum and 24/7 access.

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