The auto-complete feature in the editor can be helpful when writing button events.

As shown in blocks, ||controller:button events|| are very important for games,
as they serve as a way for the user to interact with the world the developer creates.
||controller:Button events|| in Arcade have a number of options that
allow for precise control of how the user will player the games you make.
This example shows a single ||controller:button event||,
and breaks down the difference pieces that make up the event.
controller.anyButton.onEvent(ControllerButtonEvent.Pressed, function () {
// Code that runs when the button is pressed
game.splash("A button was pressed");
});
||controller:controller||: namespace which contains functions
and values relating to the controller||controller:anyButton||: the button to set up the event for.
||controller:anyButton|| will trigger the event whenever a button is pressed||controller:onEvent||: the function used to assign an event handler,
similar to ||game:game.onUpdate||||controller:ControllerButtonEvent||: an enum (like ||sprites:SpriteKind||)
to distinguish between the different types of button events||controller:Pressed||: the property of the ||controller:ControllerButtonEvent||
that was selected.
This indicates that the event should occur when the given button is pressed||controller:A||!||game:splash||ed to “The A button was pressed”||controller:A||
button is pressed, instead of ||controller:anyButton||||sprites:Sprites|| and ||controller:Buttons||A ||sprites:Sprite|| will often serve as the main character of a game.
As such, ||controller:button|| events will often be used to control the player.
In previous lessons, ||controller:controller.moveSprite|| was introduced
to easily control ||sprites:sprites||,
but it is important to be able to control them using simple events as well.
This way, you can change the way the sprite behaves to your liking,
instead of having to stick with the default behavior.
||controller:button||(s) cause the event to triggerlet mySprite: Sprite = sprites.create(sprites.castle.princessFront0, SpriteKind.Player);
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
mySprite.x -= 5;
});
||controller:button event|| that makes the ||sprites:sprite||
move to the right when then ||controller:right|| button is pressed||sprites:sprite|| back and forth to verify that theThere are three different types of ||controller:ControllerButtonEvents||,
that occur based off the different states of the ||controller:Buttons||.
||sprites:sprite.say|| finishes,
press and hold the ||controller:A|| button.
Identify which events occurslet topSprite: Sprite = sprites.create(sprites.castle.princessFront0, SpriteKind.Player);
let middleSprite: Sprite = sprites.create(sprites.castle.princessFront0, SpriteKind.Player);
let bottomSprite: Sprite = sprites.create(sprites.castle.princessFront0, SpriteKind.Player);
topSprite.y = 30;
middleSprite.y = 60;
bottomSprite.y = 90;
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
topSprite.say("Pressed", 1000);
});
controller.A.onEvent(ControllerButtonEvent.Repeated, function() {
middleSprite.say("Repeated", 1000);
});
controller.A.onEvent(ControllerButtonEvent.Released, function () {
bottomSprite.say("Released", 1000);
});

||controller:down|| button is ||controller:Pressed||,
create a ||sprites:projectile|| that starts at the ||variables:bottomSprite||
and flies upwards||controller:up|| button is ||controller:Released||,
create a ||sprites:projectile|| that starts at the ||variables:topSprite||
and flies downwards||controller:right|| button is held (||controller:Repeated||),
increase the ||info:score|| by 1||controller:ControllerButtonEvent||s,
||controller:Pressed||, ||controller:Released||, and ||controller:Repeated||?