Label help

For questions about using Classic.

Post » Sun Dec 27, 2009 3:55 am

So... in my ship game you can zoom out. And each ship don't has a label (Ship name, position, etc.) but you zoom out and the text is unreadably small. Any ideas for a fix?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Sun Dec 27, 2009 4:24 am

[quote="YetAnotherSuperhero":3b91xclf]So... in my ship game you can zoom out. And each ship don't has a label (Ship name, position, etc.) but you zoom out and the text is unreadably small. Any ideas for a fix?[/quote:3b91xclf]

Place ship name, position etc. in something else and don't let zoom effect it.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Sun Dec 27, 2009 5:42 am

Moving to Help/Tech

[quote="Lost my Keys":1o2q05ov]Place ship name, position etc. in something else and don't let zoom effect it.[/quote:1o2q05ov]

Well, that's real specific. Do something, something, and don't let it zoom :roll:


Anyway, you could try a couple of different ways. If you set the text labels on a separate layer, then when you zoom out the lower layer the coordinates for the un-zoomed layer will be off. You will need to position your text label coordinates as a percentage of the ship layer coordinates rather than a straight one to one pixel ratio. So if your ship layer is zoomed out to 50%, your text label coordinates will have to be half what the ship coordinates are. In other words, if your ship's coordinates are 50, 180 then your text label will have to be 25, 90, etc.

The second way you could try it would be to scale the text up as you zoom the layer out. That might get a little tricky with text objects, so you might want to look into using the SpriteFont object, which should allow you to scale the sprites up. I'm not entirely sure it would work flawlessly without a lot of tweaking, but it's something to try.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 27, 2009 6:20 am

The math for this is actually more complicated than multiplying the object's position by the zoom percentage to find the text position, but I'm too lazy to explain the reasoning behind that right now. :P The formula should be as follows(this might break under certain conditions, I haven't fully tested it yet):

X = ScrollX + (SpriteX - ScrollX) * (ZoomX / 100)
Y = ScrollY + (SpriteY - ScrollY) * (ZoomY / 100)

Here's an example:

Zoom Follow Thingy

I hope this helps. :)
Moderator
B
98
S
36
G
19
Posts: 1,584
Reputation: 17,717


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests