Keeping correct x/y for objects on layer with scale rate 0

Get help using Construct 2

Post » Mon Mar 31, 2014 10:29 pm

In the game that I'm working on, I have text that appears over my character's heads. This text is on a layer with a scale rate of 0, because I don't want the text to shrink when the camera zooms out. However, the x/y positioning of the text in relation to the character gets messed up as I zoom in and out.

I've been trying to figure out the equation I'd need to use in order to keep the text properly aligned with the characters. (Currently I'm just setting the text position to character.X and character.Y) I imagine it's not a terribly complicated equation, but math is sadly not my strong suit, and the solution has been eluding me for the past hour or so..
(M.A.D. are my initials. I'm not the least bit angry, really!)
@madguy90
B
11
S
4
Posts: 41
Reputation: 1,671

Post » Mon Mar 31, 2014 11:09 pm

I thought that you could size up or down the text object in invert relation to the layout's scale (set layout scale to 2, text width/2 & height/2 || set layout scale to 1, text width*2 & height*2), or even scale the layer with the text object inside (set layout scale to 2, text layer scale 0.5 || set layout scale to 1, text layer scale 1) but for some reason it doesn't work, it does some weird stuff. Well, it works only if the layout size and window size are the same dimensions but that isn't very helpful. Maybe this is a bug, I don't know, I am confused with the parallaxing add scaling behavior in construct.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon Mar 31, 2014 11:16 pm

I know that you can, for instance, get the mouse coordinates for a specific layer using mouse.x("layer"). maybe there is a way to get something like that for other objects. (https://www.scirra.com/manual/114/mouse)
You can also, maybe, use the layer.canvasToLayerX(x) expresion. (https://www.scirra.com/manual/28/layer) not sure how it works though. but it seems to be made exactly for that purpose.
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Tue Apr 01, 2014 2:28 am

Ok, I just realized that Construct doesn't like it at all if you scale the text object! It drops the fps like crazy so I guess that it could probably cause other problems too.

I made a test capx showcasing the "zooming to the center of the window and not somewhere else" (if I may call it that) behavior. If you set the GUI layer's scale rate to 100 and try to scale the layout, the fps will fall like crazy!
I also tried the mouse.x("layer") expression that @Sargas mentions, it works as it should! I don't have the energy to further look to the layer.canvasToLayerX(x) right now and it looks more complicated.

http://www.eli0s.com/Tests/Zooming.capx

What would be very useful is to be able to specify the point of interest, in other words to have a variable defining the origin point upon which the transformations take place. Both with scaling and parallax scrolling. But this is an other topic https://www.scirra.com/forum/viewtopic.php?f=146&t=83989.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue Apr 01, 2014 8:31 pm

Making use of the LayerToCanvas expression and setting the layer's parallax to 0 is one way of dealing with this issue, but I'm having difficulty getting the text to line up properly with the buttons that I placed behind it. Kinda baffled by this one. This method still seems like a roundabout solution, and I get the feeling there's a simpler way of doing things.
(M.A.D. are my initials. I'm not the least bit angry, really!)
@madguy90
B
11
S
4
Posts: 41
Reputation: 1,671


Return to How do I....?

Who is online

Users browsing this forum: vino7733 and 25 guests