(Solved) How to retrieve a sprite X and Y positions on another Layer ?

0 favourites
  • 5 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Hello,

    I want to retrieve the position of a sprite the same way as the following expression for the Mouse objet : MouseX.("Layer A") and MouseY("Layer A").

    But this expression does not work for sprites.

    In my project, I have object A on Layer A and object B on Layer B. These 2 objects needs to apear always at the same position, but I want to change de scale of Layer A (and objet A). I want object B (on Layer B) to stay at the same position than object A on the screen.

    When I use somthing like < Every tick => set "ObjectB" position to "ObjectA" position > the coordonates of the two object will effectively remains the same even if ObjectA moves, but when I change the scale of a Layer, the two objects will be shown at different positions on the screen (even if their X and Y values are the same).

    I understand the reason of this problem, but I dont know how solve it.

    Any idea ?

  • You answered your own question though, you know the co-ordinates are correct and it's just a visual thing because you scaled the layer, so what are you asking?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I want the two sprites to appear at the same place on the screen, even if the two layers have different scale values.

  • To convert coordinates from layer A to B:

    X = CanvasToLayerX("B", LayerToCanvasX("A", x, y), LayerToCanvasY("A", x, y))

    Y = CanvasToLayerY("B", LayerToCanvasX("A", x, y), LayerToCanvasY("A", x, y))

  • Thank you soooo much ! its working perfectly !

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