DaVikingCode / Citrus-Engine

Modern AS3 Game Engine
http://citrusengine.com/
Other
555 stars 231 forks source link

ObjectMakerStarling.FromTiledMap() problem with image object positioning #244

Open jaunusa opened 9 years ago

jaunusa commented 9 years ago

I had some problems with the position of image objects I added in Tiled. Also without adding a rotation to an image object in Tiled, the position was incorrect after I parsed the map with ObjectMakerStarling.FromTiledMap(). I tried to get some help in the starling forum without success:

http://forum.starling-framework.org/topic/objectmakerstarlingfromtiledmap-image-object-transformation-problem#post-74729

Today I had a little time to find a fix, I think I found one:

//ObjectMakerStarling, line 260 - 270
const rotRad:Number = deg2rad(objectTmx.rotation);
params.x += params.height * Math.sin(rotRad);
params.y -= params.height * Math.cos(rotRad);

At the moment ObjectMakerStarling.FromTiledMap() works only with image objects if you load an atlas into the AssetManager that pass to FromTiledMap(). Would be nice if the parser would support single textures from the AssetManager. At the moment an error occurs when parsing at line 258:

params.width = Texture(params.view).frame.width;

AssetManager returns a ConcreteTexture for params.view, at that time the frame proporty of ConcreteTexture is null. Couldn't we change the lines 258 - 259 like this?

params.width = Texture(params.view).width;
params.height = Texture(params.view).height;