Jump to content

Touching screen "reset" animation with mobile


Aurelienazerty
 Share

Recommended Posts

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

  • 3 months later...
 Share

  • Recently Browsing   0 members

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