Bound to Layout: MouseX/Y goes outside layout

Get help using Construct 2

Post » Mon Nov 12, 2012 10:42 pm

This might be intended behaviour, but I'm just not sure if I'm doing it right.

I found that if I have a sprite and set the behaviour "Bound to Layout" and I create the sprite at -500/-500 on startup, the box is correctly restrained to the layout. If I also try and set the position manually it is restrained correctly. However, if I set it to Mouse.X/Mouse.Y it's possible to click near the edge of the screen and have the object poke outside the layout.



Is there something different with the mouse behaviour I should be taking into account, or should this be working in all cases?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Nov 12, 2012 11:41 pm

That's odd, can you share your .capx?
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Tue Nov 13, 2012 12:00 am

I had same issue already few months ago, which i did report as bug.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
71
S
19
G
19
Posts: 1,919
Reputation: 16,910

Post » Tue Nov 13, 2012 3:41 am

Ah, I figured it out. I'm only taking into account the window size, not the layout size. If I set the window to match the layout size (eg. 1280, 1024) I can see the sprite being constrained to the layout.

As the layout is often not the same size as the window, it's important to note then that some actions like destroying a bullet once it leaves the layout does not happen once it leaves the viewport, but the actual layout itself. In the case of huge layouts with scrolling worlds, these events might take a lot longer to fire than you expect.

I wonder how many other people this has tricked

Since we don't have a Bound to Window event, I'll have to figure out another way to constrain the sprite to the viewport. boolean2012-11-13 03:51:27
B
24
S
4
G
1
Posts: 244
Reputation: 3,462


Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, Matthew de, Skebab and 6 guests