Aurelienazerty Posted March 28, 2021 Share Posted March 28, 2021 Hi all, I modify the invader exemple here, and I wanted to make it mobile friendly. I add "button" : boutonGauche = game.add.sprite(0, game.world.height - 60, 'bouton-gauche'); boutonDroite = game.add.sprite(game.world.width - 64, game.world.height - 60, 'bouton-droit'); boutonFeu = game.add.sprite(game.world.centerX - 32, game.world.height - 60, 'bouton-feu'); And bind it : boutonGauche.events.onInputDown.add(bougerGauche, this); boutonDroite.events.onInputDown.add(bougerDroite, this); boutonFeu.events.onInputDown.add(fireBullet, this); function bougerGauche(e) { e.preventDefault(); return bouger('gauche'); } function bougerDroite(e) { e.preventDefault(); return bouger('droite'); } function bouger(mode) { if (mode == 'droite') { player.x = player.x + 5; } else { player.x = player.x - 5; } return false; } But nothing append, the animation restart each time I press on screen. Can you help me please ? invaders-reloaded.js Link to comment Share on other sites More sharing options...
Aurelienazerty Posted July 21, 2021 Author Share Posted July 21, 2021 Hi all, could you help me ? I don't understand why there is this behavior Link to comment Share on other sites More sharing options...
Recommended Posts