0 Favourites

Right side of the Layout

  • Dear all, could you help me in the following:

    I want a sprite to be placed always at the right side of the layouts (their size are different) in my game, but I cant figure out how to get the correct X. Size of the layouts could be larger than window sizes.

    I've tried:

    1) x = LayoutWidth

    2) x = CanvasToLayerX(LayerBackground,LayoutWidth,layoutHeight / 2);

    3) x = LayerToCanvasX(LayerBackground,LayoutWidth,layoutHeight / 2);

    but all i vain, the sprite is always far away from the desired position

    Will be very gratefull,

    Andy

  • Have you tried using OriginalWindowWidth and OriginalWindowHeight?

    It would look something like this sprite -> set position -> x= OriginalWindowWidth y= OriginalWindowHeight.

  • Have you tried using OriginalWindowWidth and OriginalWindowHeight?

    It would look something like this sprite -> set position -> x= OriginalWindowWidth y= OriginalWindowHeight.

    imhptep, thank you for the answer!

    it works withing window, while I've created layout that is larger than window (so i can scroll game), but it is very funny - untill now I cant get how to find programmatically the x coordinate of the layout right edge

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If you want the edge of the sprite to align with the edge of the layout, you have to take into account the sprite's origin (also called "image point 0"). You could:

    a) move the sprite's origin to the right side of the image, then use the event "sprite -> set x = layoutwidth"

    b) leave the sprite's origin in the center of the image and use the event "sprite -> set x = layoutwidth - self.width/2"

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