Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale9Sprite draw extra 1 pixel when creating from spritesheet #13564

Closed
zilongshanren opened this issue Aug 25, 2015 · 3 comments
Closed

Scale9Sprite draw extra 1 pixel when creating from spritesheet #13564

zilongshanren opened this issue Aug 25, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@zilongshanren
Copy link
Member

This issue was reported by developers from Chinese forum.
He found that when creating Scale9Sprite from spritesheet and the resulting Scale9Sprite will draw extra 1 pixel from other spriteframe.

He also proposed a solution:

Vec2 offsetPosition(ceil(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2),
                            ceil(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2));

should be changed to

Vec2 offsetPosition(floor(_offset.x + (_originalSize.width - _spriteRect.size.width) / 2),
                            floor(_offset.y + (_originalSize.height - _spriteRect.size.height) / 2));

Chinese forum:

http://www.cocoachina.com/bbs/read.php?tid=320932&page=1&toread=1#1376926

and

his blog:

http://www.cnblogs.com/songcf/p/4755193.html

@zilongshanren
Copy link
Member Author

@newnon
I remember that the ceil function was added by you.
Thoughts? How about changing ceil to floor?

Thanks.

@newnon
Copy link
Contributor

newnon commented Aug 26, 2015

I'm not sure it was long time ago. may be it is correct fix may be it will give some other artifacts

@zilongshanren
Copy link
Member Author

@newnon
I agree with you. The offset and originalSize read from plist files will be divided by ContentScaleFactor which will cause some precision lose.

I still can't make sure the fix is correct but at least it resolve the developer's issue and all the tests are good now.

I will keep a an eye with it.

Thanks for reply.

edwinkcw pushed a commit to oursky/cocos2d-x that referenced this issue Oct 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants