lewster32 / phaser-plugin-isometric

Feature-packed axonometric plugin for Phaser 2 which stays true to the Phaser API.
http://rotates.org/phaser/iso
MIT License
472 stars 165 forks source link

Pointer containment and tile asset size #9

Closed mfpierre closed 9 years ago

mfpierre commented 9 years ago

Hi,

Based on the pointer interaction if I try to use a different asset image size, like 64*32 for example, the tile.isoBounds.containsXY don't work anymore.

This line seems to be the problem, if I remove it, it works.

https://github.com/lewster32/phaser-plugin-isometric/blob/master/src/Cube.js#L583

or am I doing something wrong ?

lewster32 commented 9 years ago

That line ensures that the cube you're testing has at least some volume to it; if any of the dimensions of the cube are 0 or negative, then the cube technically has a volume of 0, and cannot contain a point. Maybe though, in this case, the function should not be checking height, as height is not a requirement for the XY check anyway. I wonder if the line should be changed to:

if (a.widthX <= 0 || a.widthY <= 0) {

Could you upload an example so I can be sure this is the issue before I make any changes?

mfpierre commented 9 years ago

Okay, the height is definitely the issue here because for a 64x32 tile the height calculated is 0 (32 - 64/2).

Here is the fiddle to test the issue http://jsfiddle.net/zbm95089/

This is a problem because I can not make "flat" tiles having mouse interactions (typically the floor tiles).

lewster32 commented 9 years ago

Excellent, thanks for spotting and fixing! :+1: