odrick / free-tex-packer

Free texture packer
http://free-tex-packer.com/
MIT License
911 stars 168 forks source link

Image coordinate offset value is missing #24

Closed 942Avril closed 5 years ago

942Avril commented 5 years ago

Image coordinate offset value is missing

Export the cocos2d project and find that spriteOffset is always {0,0}

odrick commented 5 years ago

Fixed. Please, check here: http://free-tex-packer.com/test/

942Avril commented 5 years ago

Can be used, but the result has a floating point value

942Avril commented 5 years ago

The calculated offset value is incorrect

odrick commented 5 years ago

Do you have an examples for me? With correct values.

942Avril commented 5 years ago

example.zip The texturePacker folder is the result of exporting with texturepacker. The freeTexPacker folder is the result of exporting with the link you sent. The sourceImg folder is the source file.

odrick commented 5 years ago

Ok, fixed. Please, try again: http://free-tex-packer.com/test/ Floating point offset values are valid: https://www.codeandweb.com/blog/2016/01/29/cocos2d-plist-format-explained

Calculation offset formula:

spriteSourceSize.x + spriteSourceSize.width/2 - sourceSize.width/2

(the offset of the sprite's untrimmed center to the sprite's trimmed center)

For example:

spriteSourceSize: x=320, y=55, width=193, height=399 sourceSize: width=800, height=800 offset.x = 320 + 193/2 - 800/2 = 16.5

FTP pack results: pack-result.zip