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

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • 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..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)