Jump to content

Mouse is down for moble

Mohammed Salman

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 (
            ) {
                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) {

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


  • Recently Browsing   0 members

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