Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Mouse is down for moble


Mohammed Salman
 Share

Recommended Posts

I have been looking for a solution for a while now!

the idea is to move the zombies to the point i hold the mouse in and stop when i release the mouse, this is my movement code:

//check mouse down
    if (game.input.mousePointer.isDown) {
        //move all zombies
        zombies.forEach(function(zombie) {
            game.physics.arcade.moveToPointer(zombie, 400);

            //if in box reset velocity
            if (
                Phaser.Rectangle.contains(
                    zombie.body,
                    game.input.x,
                    game.input.y
                )
            ) {
                zombie.body.velocity.setTo(0, 0);
            } //end if
        }, this); //end forEach
    } else {
        zombies.forEach(function(zombie) {
            zombie.body.velocity.setTo(0, 0);
        }, this); //end forEach
    } //end else

    if (game.time.now > nextFire) {
        fire();
    }

basically what i want is to check for the same input in mobile devices, i have tried using:

game.input.onDown.add(move , this);

but it didn't work well for me because the zombies kept on going on that direction forever.

please help:(

this is the full code: http://github.com/msal4.github.io/increment/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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