detecting near edge of layout

Post » Sat Apr 01, 2017 1:33 pm

I am wondering if there's a way to detect the layout edge? Anyone got a quick tip?

I see we have is on screen and is outside layout, but no touching layout edge? Seems like a really simple feature that should be built in.
B
4
S
2
G
5
Posts: 346
Reputation: 2,417

Post » Sat Apr 01, 2017 2:00 pm

You could compare width and height of this viewport size.

If a mouse position as x is greater than width of viewport (window is 854 x 480, in that case youre comparing with 854) you can detect right of edge.

Else if a mouse position as x is lesser than zero to get negative width of the layout, you can detect left of edge


Also it can apply to y of top and bottom
Last edited by Joannesalfa on Sat Apr 01, 2017 4:21 pm, edited 1 time in total.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Sat Apr 01, 2017 3:43 pm

Put an invisible 4x4 px sprites at the edges of your layouts.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,244

Post » Sat Apr 01, 2017 5:34 pm

liamdawe wrote:I am wondering if there's a way to detect the layout edge? Anyone got a quick tip?

I see we have is on screen and is outside layout, but no touching layout edge? Seems like a really simple feature that should be built in.


There's the "Bound to Layout" behavior, to keep objects in layout, but agreed having something to reference to see if you're near the edge would be handy.
B
84
S
46
G
25
Posts: 530
Reputation: 21,570


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests