Jump to content

Attack with left click


danteAGAIN
 Share

Recommended Posts

Hello everyone,

I need your help , i try create a "rpg game" . I want use the left click (mouse1) for auto atk with my hero. my code:

 

create: function(){

this.player.animations.add('atk', [529, 532, 535, 538, 541], 10, true);

}

update: function(){

if(game.input.activePointer.isDown){

this.player.animations.play('atk');

}

 

with this code i need to keep my left click to push for see the action. And i want just to push 1 time.

Sorry my english is very bad.

Link to comment
Share on other sites

You want to use the onDown signal on game.input:

 

create: function(){
    this.player.animations.add('atk', [529, 532, 535, 538, 541], 10, true);

    this.game.input.onDown.add(function () {     
        this.player.animations.play('atk');
    }, this);
}

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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