Jump to content

HitArea - Phaser 2.0.0


rykket
 Share

Recommended Posts

Hi,

 

I can´t find any information on how to use the new hitArea property for Phaser 2.0.0, I want to use this to check whether the face of a character is clicked/pushed or if it the rest of the body that is clicked. I am pretty new to Phaser so hopefully someone can help me at either showing me where to find the documentation on this or give an example of how to set an area and how to check if this area is clicked.

 

Thanks in advance!

 

 

Link to comment
Share on other sites

Hi,

 

Thanks for the reply. Only need it for input handling so should be ok. In Pixi i see the hitarea property is defined by i.e: 

sprite.hitArea = new Pixi.Rectangle(x0,y0,x1,y1)

. Can I use that with Phaser? 

 

Two more questions:

 

Can I define several hitareas on a sprite?

 

How do you detect the different hitareas on a input? Do you define something like:

sprite.hitArea[0].events.onInputDown.add(sprite.onFaceClick, this);

?

Link to comment
Share on other sites

1) They can only have 1 hit area, which is 1 shape. So that is why it doesn't send the hit area to the callback, as it's a property of Sprite anyway.

 

2) Yes you use it like that, but use a Phaser geometry object. So Phaser.Rectangle, Phaser.Circle, etc.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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