Right side of the Layout

Discussion and feedback on Construct 2

Post » Sat Jul 01, 2017 8:49 am

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
B
9
S
2
Posts: 34
Reputation: 603

Post » Sat Jul 01, 2017 10:26 am

Have you tried using OriginalWindowWidth and OriginalWindowHeight?

It would look something like this sprite -> set position -> x= OriginalWindowWidth y= OriginalWindowHeight.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Sat Jul 01, 2017 2:33 pm

imhotep22 wrote: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 :)
B
9
S
2
Posts: 34
Reputation: 603

Post » Sat Jul 01, 2017 2:45 pm

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"
Eh, Steve!
B
115
S
54
G
13
Posts: 113
Reputation: 16,151


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests