rykket Posted March 14, 2014 Share Posted March 14, 2014 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 More sharing options...
rich Posted March 14, 2014 Share Posted March 14, 2014 Ah this is a Pixi level feature, so you can learn how to use it by looking at their docs until we get around to adding it to ours! Note it's just for input handling, not physics. Link to comment Share on other sites More sharing options...
rykket Posted March 14, 2014 Author Share Posted March 14, 2014 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 More sharing options...
rich Posted March 14, 2014 Share Posted March 14, 2014 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 More sharing options...
Recommended Posts