How not to have numbers overlap with labels in one block


Example


If you have something like a score tracker or a money counter and only use set text, then the number will overlap with the label when it gets too big. An easy way to fix this is to use the new when game is playing block with a set position inside.



Start by setting the position of the number to the position of the label. The y position will stay the same, so leave it alone now. Next you move the number to be on the very right edge of the label. (Or left, if you’re doing a label after the number.)

If you divide an object’s width by two, you get a number which when added to its x position will result in the x coordinate in the right edge, and when subtracted, its left edge. But this code will always overlap. You need to add half of the width of the number to get it to never overlap.



This should make sure that it never overlaps.

15 Likes

Nice tutorial

4 Likes

well explained tutorial! great job.

4 Likes

I have actually wondered about how to do this in the best way possible, and this is a very neat method! Thanks for sharing.

5 Likes

This is actually very handy lol, thanks for showing us this :blush:

1 Like

Great use of the width variable, well done

2 Likes

This code rocks! Thanks for the discovery!

2 Likes