Clickteam Fusion 2.5

Clickteam Fusion 2.5

Not enough ratings
A Guide to Basic Object Scoping in Clickteam Fusion 2.5
By DannyUK2k14
Sometimes in Clickteam Fusion 2.5, you may have one object but lots of instances of this one object. Sometimes you need to be able to distinguish, in the event editor, which object to apply certain actions to. This is not an exhaustive guide on object scoping, this is an introduction to object scoping.
   
Award
Favorite
Favorited
Unfavorite
Introduction
Sometimes, when you create your computer game, you may have one type of enemy placed all over the level. Sometimes, you may want certain conditions or actions to concentrate on just one of those objects instead of all of them.

If you don't 'scope down' then Fusion 2.5 will, in most cases, apply the action to ALL of them same objects. For instance, if we have 1 object in our frame called, Active that has 4 frames representing a colour like so:



Here are it's animation frames:



With the animation speed set to 0. We don't want to animate, just have 4 frames to choose from.

You can see here, we are using the object called 'Active' and we have 3 x Actives in the playarea. If we do an event say, Start of Frame: Set Animation Frame to 1 (which is Frame 2 as it is 0-based, so 1=0, 2=1 etc.) it will apply the same to all like so the end result telling all 3 Actives to display frame 2 (Yellow) like so...



Now, we might want to display them all as red until a user puts their mouse over one of the actives and we display that one as yellow like so...



This is where scoping comes in. We tell Fusion 2.5 in our events to select only objects that meet a certain criteria. Object scoping in Fusion 2.5 can get DEEP, very deep! This is a great thing, as it gives you complete control over referencing individual instances of objects.

In the proceeding pages, we will setup a 'test case' in the playarea and perform some eventing to scope down to particular objects.
Setting Up Your Playarea
Ok, let's get started on creating this little test. Create a new application, jump into the frame editor and insert an Active Object.



Drop it into the playarea, preferably around the middle. Double-Click the Active to edit it. Now create 4 frames by copy/pasting like so...



Once you have 4 frames, paint them all a different colour. You can use the 'Bucket Tool' to fill them in a particular colour from the colour palette. When you click the Bucket Tool, make sure you put the Tolerance Level to 100, this will fill it in quicker.



Paint each one a different colour. In this example, we will use Red, Yellow, Green, Blue.



Then click on the tab 'Direction Options' and turn the animation speed down to 0. This means the object will not animate through the frames, rather stay static. We will tell it which frame to display in the events on the next section, when we 'scope down'.

Click OK. Once the dialog has closed, place the Active somewhere in the centre of the playarea, then drag some more (2,3,4,5) as many as you want, into the play area. You can setup the playarea to look how you want, we just need lots of Active objects on there. For the purposes of this guide, we've set it up like this



Now let's jump into the event editor and make some magic with 'scoping down'.

Implementing Events
Ok so now we are in the frame editor, we are going to do some very simple and basic scoping techniques. If you understand how events work, which I would assume you do, you have 'conditions'. When a 'condition' or a set of 'conditions' are met, actions that you set are performed on objects. IF the condition is ambiguous or has no relevance to an object, any actions performed on a given object is applied to ALL objects. For example, Start of Frame condition is ambiguous, it doesn't reference any objects in the condition. So any actions on this event line to say our Active Object is going to be applied to ALL those active objects because the condition itself doesn't contain the active object.

If the condition was something like X Position of “Active” object is greater than 100, then any actions performed on ACTIVE object in that event line will only apply to those ACTIVE objects that have an X Position greater than 100. The ACTIVE objects that are 100 or less on the X Position will not be affected. This is because we are looking for ACTIVE object that is greater than 100 to apply an action/some actions to, so those that don't meet the condition are not affected.

So, let's insert our first condition and hopefully this will click together easier.

Insert a new condition, right-click on the Special Object and select Always.



The event editor (at runtime) runs events top to bottom, everytime it runs through all the events, that is called a 'tick', so the condition 'Always' means every tick. So every tick, it will apply whatever actions we have in this event line.

Once inserted, hover across to the ACTIVE object, right-click and select Animation > Change > Animation Frame...



When the expression editor pops up, insert 0. This is to show 'Frame 0' which is effectively Frame 1. When referencing frames from the event editor, it is 0-based, so 0=1, 1=2 etc.



Click OK. Now, let's create another event, insert a new condition, right-click on the KeyBoard & Mouse Object and select 'Check for Mouse Pointer over an object'



In the dialog prompt, select the ACTIVE object.



Click OK. Once inserted, hover back over the ACTIVE object on this event line, right-click and again, select Animation > Change > Animation Frame (as above). In the expression editor when it pops up, type in 1 and Click OK.

Ok, let's RUN out application and test this out. Hit F8 to run your application. You will see that the ACTIVE object is ALWAYS displaying red, now hover your mouse over any of the ACTIVES and see it turn yellow. That's because we told ALL the objects in the first event to ALWAYS be red (frame 0) and ONLY when our mouse overlaps one of them turn them to yellow (frame 1).

So, in two events you should now know the basic concept behind object scoping. If you reference an object in the conditions, Fusion 2.5 will iterate through all the objects to find which one(s) match the condition and then apply the action(s). If NO object is referenced in an event (condition), then it will apply the action(s) to ALL the instances of that object.
Extra Test
I strongly recommend you play a little further with object scoping. It will prove very useful to you in the future when developing applications or games with Fusion 2.5.

Just as a little extra, try deleting the actions from the events we just wrote and replacing them with something else. For example,

Always: Make Object Invisible
Mouse is Over Object: Make Object Reappear

or

Always: Set Semi-Transparency to 128
Mouse is Over Object: Set Semi-Transparency to 1



3 Comments
aabicus 3 Jan, 2015 @ 7:02pm 
That's what I needed to know! Was trying to hide an object only when the mouse was hovering over it. Thanks!
demon32 31 Dec, 2014 @ 6:05pm 
interesting information now if only the android add on worked . All it tells me is to add the path to the jdk and sdk even after ive already added them in preferences . It wont allow me to compile anything
Cutter 9 Jul, 2014 @ 12:03pm 
thanks