HaxePunk / tiled

Tiled TMX import for HaxePunk
50 stars 18 forks source link

Zero size objects work in game, but not during debug #35

Open DaVince opened 9 years ago

DaVince commented 9 years ago

When I run a game without debug mode, the game will run and properly recognize objects (as signified by the fact that I use a "startpoint" object that is 0 wide, 0 high, and positioned in a specific place).

But when I try to run this same game in debug mode, the game crashes and outputs this in the console:

Illegal rect, sizes cannot be 0.

Same bug for circle object, though then the error there is "radius".

ibilon commented 9 years ago

That's coming from haxepunk's image class. But that's strange, this check isn't debug only, it should throw even in release.

scriptorum commented 9 years ago

That's from TmxObject.hx, it creates a rect in debug mode only:

#if debug
            debug_graphic = com.haxepunk.graphics.Image.createRect(width, height, 0xff0000, .6);
            debug_graphic.x = x;
            debug_graphic.y = y;
#end
DaVince commented 9 years ago

So what happens now? Should TmxObject.hx be fixed to create a 1x1 rect/circle in cases like these? Or should I always make my objects at least 1x1 big in Tiled? (That'd be a chore, frankly.)

scriptorum commented 9 years ago

If 0x0 is a legal size, that doesn't sound like an awful solution (modify TmxObject to draw a 1x1). However, also note that the TMX file is just XML: you could throw it into a text editor and replace all height/width="0" to ="1" pretty quickly.