Jump to content

For touch/activepointer, is there a onDown (which runs just once) instead of isDown (which runs 60 times)? Couldn't find in docs


Recommended Posts

        if((game.input.activePointer.isDown && game.input.activePointer.x < game.width/2))

On tap, the above runs 60 times a second. Instead, I only want it to run just once onDown and ideally, again on onUp. Just like we can do with keys.

        leftKey = game.input.keyboard.addKey(Phaser.Keyboard.LEFT);
        leftKey.onDown.add(addHookLeft, this);
        leftKey.onUp.add(removeHookLeft, this);



Link to comment
Share on other sites

1 minute ago, drhayes said:

It look like you're making screen controls, right? What if you made big, invisible sprites and then used their "events.onInputDown"?

yes screen (as well as keyboard). Hmmm, thats a good idea. I just hoped phaser had something built-in for this. thank u sir 

Link to comment
Share on other sites

2 minutes ago, Tom Atom said:

Hi, you can add callbacks for mouse down, drag and mouse up:

            // Set up handlers for mouse events
            this.game.input.onDown.add(this.mouseDown, this);
            this.game.input.addMoveCallback(this.mouseMove, this);
            this.game.input.onUp.add(this.mouseUp, this);


Tom, the thing is, in my game, I have the screen split into two, so if they press on the right side this happens and left side that happens. Activepointer gave me the option to check the pointer.x 

Link to comment
Share on other sites

On 06/05/2016 at 5:52 PM, Tom Atom said:

you can make your onDown handler like this:

        public mouseDown(pointer: Phaser.Pointer) {

... and read from passed pointer whatever you need.

This works perfectly!! Thanks again! 

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...