Skip to content

How to use Scale9 sprite? #2356

Closed Answered by rh101
paulocoutinhox asked this question in Q&A
Jan 30, 2025 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

You can only set the left, right, top and bottom values, so based on this image:

These are the corresponding settings:

balloon->setInsetLeft(L);
balloon->setInsetRight(R);
balloon->setInsetTop(T);
balloon->setInsetBottom(B);

Also, in order for the sprite to render the corners correctly, the final content size must be greater than the size of the total X and total Y inset sizes combined.

So, minimum content size is:
balloon->setContentSize(L+R, T+B)

So, for your example,:

Size balloonSize(std::max(textSize.width + padding * 2, L + R), std::max(textSize.height + padding * 2, T + B));

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@paulocoutinhox
Comment options

@paulocoutinhox
Comment options

@rh101
Comment options

rh101 Jan 30, 2025
Collaborator

Comment options

You must be logged in to vote
5 replies
@paulocoutinhox
Comment options

@rh101
Comment options

rh101 Jan 30, 2025
Collaborator

@paulocoutinhox
Comment options

@rh101
Comment options

rh101 Jan 30, 2025
Collaborator

Answer selected by paulocoutinhox
@paulocoutinhox
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants