by Jon (Updated on 2014-01-29)
As a recap from before, Events are the building blocks of Behaviors. In short, they’re things that happen in your game that can trigger some kind of action, or response.
Returning to our vertical shoot ‘em up example, recall that when the player presses the spacebar, the player’s ship fires a laser. In this case, hitting the spacebar is the event, and firing the laser is the response. The event and response are related by cause and effect.
Stencyl includes a large number of events that developers can take advantage of.
Happens once when the Behavior is initialized.
All drawing code goes here. Usually happens once a frame. The difference between this and "When Updating" is that this code happens at a different time in the "game loop." As such, it is best to only perform drawing operations inside When Drawing.
Happens for every frame of the game.
Game gains/loses focus. Web games only.
Mouse enters/exits/presses/releases/drags on an actor.
Mouse enters/exits/presses/releases/drags on a region.
Runs the code after the given delay.
Runs the code every N seconds.
Game paused/unpaused. Read our article on Pausing.
Actor is Created/Killed.
Actor of Type is created/killed.
Member of group is created/killed.
Actor enters/leaves the Screen/Scene.
Actor of type enters/leaves the screen/scene.
Member of group enters/leaves the screen/scene.
Actors enters/leaves a Region. Read our article on Regions.
Actor of type enters/leaves a region. Read our article on Regions.
Member of group enters/leaves a region. Read our article on Regions.
Happens when this actor collides with another actor.
An actor collides with another actor.
An actor collides with another actor of type.
An actor collides with another actor of group.
An actor of type collides with another actor of type.
A member of group collides with another member of group.
Sound is done. Read about Sound Playback.
Channel is done. Read about Sound Channels.
Number becomes greater/less than number.
Attribute becomes equal/not equal to attribute.
Boolean becomes true/false.
Happens when a Behavior uses the “trigger event” block (such as ‘onClick’ for button click). Similar to a function call but without parameters. Read our article on Custom Events.
A customizable form of ‘when [ ] happens’ that allows new blocks to be created. Read our article on Custom Blocks.
A customizable form of ‘when [ ] happens’ that allows new blocks to be created but isn’t tied to an actor or scene. Read our article on Custom Blocks.
Arbitrary code that lives outside of regular events. Stick in the multi-line code block (under Flow > Advanced) to use this.
Import statements for coders. Stick in the multi-line code block (under Flow > Advanced) to use this.