xraven13 / FlxSpineSprite

Spine for Haxe & HaxeFlixel . ( bone based animation system )
12 stars 2 forks source link

Skeleton scaling problem #8

Open xraven13 opened 11 years ago

xraven13 commented 11 years ago

When rendering code doesn't take in account scaling of SkeletonJson. So if you set the Scale value to any value other then 1 result will not be good. This is really useful because this way original bitmap can be set to smaller size, and is not needed to change the scale of flxsprite. Also, I am not sure, but it seems to me when I was testing before bounding boxes wasn't scaled properly when I changed scaling of sprite instead of scaling of json skeleton.

public static function readSkeletonData(DataName:String, DataPath:String, Scale:Float = 1):SkeletonData { if (DataPath.lastIndexOf("/") < 0) DataPath += "/"; // append / at the end of the folder path var spineAtlas:TextureAtlas = TextureAtlas.create(Assets.getText(DataPath + DataName + ".atlas"), DataPath, new FlixelTextureLoader()); var json:SkeletonJson = SkeletonJson.create(spineAtlas); json.setScale(Scale); var skeletonData:SkeletonData = json.readSkeletonData(DataName, Assets.getText(DataPath + DataName + ".json")); return skeletonData; }

gamedevsam commented 11 years ago

From what I understand scaling should be working with normal FlxSprite scale property. We should remove this argument if it breaks things.

xraven13 commented 11 years ago

It is kinda more handy if u can set scale via json cause then u dont need to memorize start scale. Also not sure are debug rects set properly when flxsprite is scaled.

On 19 Jul 2013 01:18, "Samuel Batista" notifications@github.com wrote:

From what I understand scaling should be working with normal FlxSprite scale property. We should remove this argument if it breaks things.

— Reply to this email directly or view it on GitHubhttps://github.com/xraven13/FlxSpineSprite/issues/8#issuecomment-21222006 .

xraven13 commented 11 years ago

Yeah problem is in debug boxes. Those debug boxes are actually used for overlap test so they are important if you want to test is for example sword hitting enemy. I tried setting scale for different stuff to make the bounding boxes size right, but I didn't succeed yet. Any suggestion ? thx

gamedevsam commented 11 years ago

Unfortunately it isn't that simple. Each body part is implemented as an FlxSprite. FlxSprites use very basic AABB collision checks to determine if things are colliding or not. This system doesn't support scaled or rotated collision volumes, it only a simple rectangle check.

That means there's only 4 variables that govern collision: x, y, width, height

If you want more fine grained control, you will have to implement your own system of collision checks.

xraven13 commented 11 years ago

Yeah, that is okay. So I should just ignore bounding boxes in debug or ? Would be nice if I could see them ... They are not the sprites used for colliding ? If not, which ones are they ? I am gonna use SAT overlap.

2013/7/21 Samuel Batista notifications@github.com

Unfortunately it isn't that simple. Each body part is implemented as an FlxSprite. FlxSprites use very basic AABB collision checks to determine if things are colliding or not. This system doesn't support scaled or rotated collision volumes, it only a simple rectangle check.

That means there's only 4 variables that govern collision: x, y, width, height

If you want more fine grained control, you will have to implement your own system of collision checks.

— Reply to this email directly or view it on GitHubhttps://github.com/xraven13/FlxSpineSprite/issues/8#issuecomment-21308757 .

xraven13 commented 11 years ago

Ok, got it, I will write here code when I implement it properly. But wrapper FlxSprites are the key.

2013/7/21 Kris Mac xraven13@gmail.com

Yeah, that is okay. So I should just ignore bounding boxes in debug or ? Would be nice if I could see them ... They are not the sprites used for colliding ? If not, which ones are they ? I am gonna use SAT overlap.

2013/7/21 Samuel Batista notifications@github.com

Unfortunately it isn't that simple. Each body part is implemented as an FlxSprite. FlxSprites use very basic AABB collision checks to determine if things are colliding or not. This system doesn't support scaled or rotated collision volumes, it only a simple rectangle check.

That means there's only 4 variables that govern collision: x, y, width, height

If you want more fine grained control, you will have to implement your own system of collision checks.

— Reply to this email directly or view it on GitHubhttps://github.com/xraven13/FlxSpineSprite/issues/8#issuecomment-21308757 .