I’m trying to create a GameObject represented as a polygon, and I want to highlight it on mouse-over. I tried this:
var points = [-50, -50, 0, -50, 50, 0, 0, 50, -50, 50]
var pl = scene.add.polygon(400, 1200, points, 0xFF0000)
pl.setInteractive(pl.points, Phaser.Geom.Polygon.Contains)
pl.on(Phaser.Input.Events.GAMEOBJECT_POINTER_OVER, function(){pl.fillColor = 0xFF6060} , this)
pl.on(Phaser.Input.Events.GAMEOBJECT_POINTER_OUT, function(){pl.fillColor = 0xFF0000}, this)
scene.input.enableDebug(pl, 0xff00ff)
However, I see the debug is showing me the hit area is actually a rectangle with the upper right corner at coordinate (0, 0, w=100, h=100). I tried playing with setOrigin
on the polygon, but it shift both the filled polygon and the hit area.
- How do I center the hit area around my polygon?
- why is the hit area not reflecting the shape of the polygon (i.e. is rectangular)?