Jump to content

Input keyboard SPACEBAR


danteAGAIN
 Share

Recommended Posts

Hello everyone,

 

can you told me why my code is not working ? i don't understand why is not working, i got inspired with this : https://phaser.io/examples/v2/input/keyboard-hotkeys 

my code:

function preload(){

    game.load.image('bulleRpg', 'assets/bulleRpg/bulleRpg.png');

}

var spaceKey;

function create(){

    spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
    spaceKey.onDown.add(drawBulleRpg, this);

}

function drawBulleRpg() {
    game.add.sprite(game.world.centerX + 250, game.world.centerY + 150, 'bulleRpg');
}

 

i want just display an image when i press the spacebar. Thx lot of

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...