Construct 2 Tutorial – Flash Behavior

Construct 2 Tutorial – Flash Behavior


Not all of the Behaviors affect an object’s
movement, some Behaviors, like the Flash Behavior, only affect an object visually. The Flash Behavior can be used to make an
object flash, or blink on and off. It does this by turning the object’s visibility
on and off over a chosen period of time. When making a game, there are times when you
want to draw the attention of the player to a certain object on the screen, like when
they receive a message, or if they have skill points to use. You could have a skill point icon flash, drawing
the player’s attention. Then, they could click the icon, taking them
to the level up page. When they return to the game, the icon would
have stopped flashing. This is all possible, and actually very easy,
with the Flash Behavior. In this layout, I have three chests underwater. They have no Behaviors added to them, they
are just one frame sprites. Let’s go ahead and add the Flash Behavior
to the Chest object, by selecting Behaviors, Add New, and then Flash, under General. The Flash Behavior has no parameters, and
it has to be activated in the Event sheet. I’ve seen a few people having trouble with
this. They add the Flash Behavior to an object,
then see that there are no parameters, test the layout out, and nothing happens. They get frustrated, and remove the Flash
behavior. But, using the Flash Behavior is so easy,
that it really isn’t a problem using the event sheet. Let’s switch to the Event sheet, and take
a look at some examples. First, let’s just make the chests flash
at the start of the layout. Click Add Event, System, and select On Start
of Layout, under Start & end. That means at the start of the layout, this
event will be triggered. We just need to add an action. Select Add Action, but this time select Chest. The Chest object has the Flash Behavior applied,
so you can only activate it by selecting the Chest object. Scroll down to Flash, and we have two options,
Flash, and Stop Flashing. I’ll choose Flash, and that brings up this
window, with 3 options. On time, Off time, and Duration. On time is the duration of time that the object
is visible, and Off time is the amount of time the object is invisible. Duration is the length of the entire cycle,
the object will flash on and off as many times as it can over the duration of one second,
in this example. Hit done, and then preview the layout. When the layout starts, all of the chests
flash for one second. Easy enough, but what if we wanted a single
chest to flash? This time, I’ll set it up so that the chest
begins flashing after the user clicks on it. The chest will flash for one second, and then
be destroyed. I’ll delete the event we set up, and create
another one. For this example, I’ve added the Mouse object,
since we need to tell when the chest is clicked. Click Add Event, and select Mouse, and then
On Object Clicked. I’ll leave these settings to their default,
but we need to set Object Clicked to the Chest object. Now we need to add an action, this time using
the Chest object. I’ll select Flash, and leave it to the default
settings. If I preview the layout, and click on a Chest,
that Chest begins flashing. The reason that this chest flashes, and not
all of the chests, is because of the Mouse Click event. When you click the Chest, Construct selects
that instance, if you choose to perform an action on it. Let’s add one more Event, which will be
triggered by the Chest. We want to destroy the chest after the Flash
effect has stopped, so under Flash, choose On Flash Ended. Click Add Action, select Chest, and under
Misc, choose Destroy. Now, I’ll preview the layout, and click
on one of the chests. It flashes for one second, and is destroyed. I can click the others, and the same thing
happens. Flash, and destroyed. By using the Flash Behavior you can draw attention
to objects when necessary. Many games have flashing items, and without
this Behavior, you’d need to write code to cause each of those objects to flash, and
even more code to determine when they stop flashing, or if they are destroyed at the
end of the cycle. The Flash Behavior can quickly add so much
to your game, that it’s important to understand how to use it. Thanks for watching. If you found this content helpful, please consider supporting me on Patreon. Comment, like and share this video, and subscribe for more tutorials. See you next time.

2 thoughts on “Construct 2 Tutorial – Flash Behavior”

Leave a Reply

Your email address will not be published. Required fields are marked *