How to make a player attack
First read the tutorial How to make a Platform game
This tutorial is a "continuation" of "How to make a Platform game".
Now how make a player atack: in player add a animation for the atack, my animation name is Ata. In PlayerBox add a instace variable
now go event sheet add event: key on pressed, put key space, and add sub event: playerbox istanci variable, is boolean istanci variable set, invert the event, add action: playerbox instanci variable, set boolean, true.
now go event sheet add event: playerbox istanci variable, is boolean istanci variable set, add action: player set animation "Ata". now add sub event: Play on colisium with Snailenemy, add action: snailenemy destroy
now go event sheet add event play animation on finish "Ata", add action: player box set boolean false. add sub event playerbox is moving, add
action: player set animation "Run", add sub event playervox is moving, invert, add action: player set animation "Idle".
now the rest we will check with the animation is atack or not atack, images of event sheet: