Jump to content

Having a positive frameX, frameY


Dannysw
 Share

Recommended Posts

So I have exported a starling atlas from flash professional, which has given me something like 
 

<SubTexture name="ResizedSpritesheet0014" x="158" y="366" width="214" height="213" frameX="-16" frameY="-20" frameWidth="235" frameHeight="227"/>
<SubTexture name="ResizedSpritesheet0015" x="372" y="366" width="413" height="360" frameX="76" frameY="64" frameWidth="235" frameHeight="227"/>

However when the xml data is parse it grabs the absolute values for frameX and frameY which means that my positive offset ends up being moved in the same way as the negative ones.
frameX = Math.abs(parseInt(frame.frameX.value, 10)); 
frameY = Math.abs(parseInt(frame.frameY.value, 10));
 
 
 
I've changed the Math.abs to just use 
frameX = -(parseInt(frame.frameX.value, 10));frameY = -(parseInt(frame.frameY.value, 10));

which seems to have fixed my issue, but really don't want to modify anything in Phaser like that, if anyone has any clues it'd be helpful.

Link to comment
Share on other sites

The negative offset from what I understand is the amount of extra transparent padding your image had before Starling cropped it to save space in the atlas graphic. And then this trimmed space gets added back at runtime.

So...presumably if you have frameX and frameY as -16, if you plot your Sprite at 0,0 then it will look like it is at 16,16 but that is expected behaviour, because the top left part is transparent... And presumably the transparency is included in the hit area of the sprite,as it's just pixels with an alpha value of 0

Phaser obviously already expects the value to be negative, which is why they are using abs.

Unless I've missed something. I've not actually used it but maybe you expected it to work differently?

Link to comment
Share on other sites

The negative offset from what I understand is the amount of extra transparent padding your image had before Starling cropped it to save space in the atlas graphic. And then this trimmed space gets added back at runtime.

So...presumably if you have frameX and frameY as -16, if you plot your Sprite at 0,0 then it will look like it is at 16,16 but that is expected behaviour, because the top left part is transparent... And presumably the transparency is included in the hit area of the sprite,as it's just pixels with an alpha value of 0

Phaser obviously already expects the value to be negative, which is why they are using abs.

Unless I've missed something. I've not actually used it but maybe you expected it to work differently?

 

 

 

Ahh cool thanks. Yeah that makes sense.

 

For some reason Flash Professional decided to give me an image that is larger than the frame width, and frame height. Which is probably why it is using a positive value. Just ended up resizing my frameWidth/Height on all of the subtextures, and updated all of the frame values to account for it. Means a few things aren't aligned any more but I can deal with that :).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...