Jump to content

How to check if touch is not on text?


DELETE THIS ACC PLS
 Share

Recommended Posts

Hi,

 

I'm trying to make a pause function for my Open Source game, Flappy Box.

 

I got the pause to work, but when you click "pause" text, the Box jumps. So I want to trigger the jump function only when pause is not touched.

Here's what I use to trigger the jump function:

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

Simple, right? Thanks in advance.

Link to comment
Share on other sites

Oh I see, so clicking 'pause' sets off the jump too? I guess you should have something to check if it's over the pause text:

if (game.paused === true || game.input.hitTest(pauseText, game.input.activePointer)) {  return;}

I think that should work. Not entirely sure about the third parameter in hitTest.

Link to comment
Share on other sites

In that case try this:

if (game.paused === true || Phaser.Rectangle.containsPoint(pauseText.getBounds(), game.input.activePointer.position)) {  return;}

You may want to store the result of getBounds() somewhere rather than calculating it each frame if your pauseText doesn't move or change size.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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