Copy link to clipboard
Copied
hey,
i want to create platform game in as3.
can someone send/write me the code that say: if i press the mouse key the player jump else he stand on the ground.
thanks(-:
Copy link to clipboard
Copied
AS3 relies on event listeners for just about everything. If you want to have something hapen as a result of a mouse interaction then you need to use an event listener for that.
addEventListener(MouseEvent.MOUSE_DOWN, doSomethingDown);
function doSomethingDown(evt:MouseEvent):void {
// put whatever you plan for jumping code here
}
addEventListener(MouseEvent.MOUSE_UP, doSomethingUp);
function doSomethingUp(evt:MouseEvent):void {
// put whatever you plan for stopping the jumping here
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now