Jump to content

executing function from mouse instead of keyboard issue


Recommended Posts

Good day,

I was trying to modify the example code below, to load up power and fire with mouse. The load up is working great, but there seems to be some issues when im calling the function fire() from mousePointer.isUp.

This is the code I currently have, it seems to be executing only once, than it freezes up, it stops loading new powersettings, but the moving functions seem to be working fine!

                if (this.input.mousePointer.isDown && this.power > 0 && this.power < 50)
                    this.power += 1;
					this.loaded = true;
                else if (this.power == 50){
					this.power = 50;
					this.loaded = true;
				} else
                    this.power = 1;
				  if (this.input.mousePointer.isUp && this.power > 0 && this.power < 51 && this.loaded)
					this.loaded = false;
					//this.add(this.fire, this);
					this.power = 1;

Example codes.


this.fireButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
this.fireButton.onDown.add(this.fire, this);
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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