How do I detect edge of screen?

Get help using Construct 2

» Mon Jan 26, 2015 10:30 am

Hi all,

is there a way to determine if my character is on the left or right edge of the visible screen? I want to limit his movement based on the screen device. I dont want the character to go off the screen since there is no scroll on him. Something like bound by screen would be ideal
B
8
S
4
G
1
Posts: 191
Reputation: 1,878

» Mon Jan 26, 2015 1:07 pm

marcel1980 wrote:Hi all,

is there a way to determine if my character is on the left or right edge of the visible screen? I want to limit his movement based on the screen device. I dont want the character to go off the screen since there is no scroll on him. Something like bound by screen would be ideal

there is a behavior https://www.scirra.com/manual/89/bound-to-layout

if you want to use another way, you can make 4 invisible wall and set x,y, and use:

ViewportBottom(layer)
ViewportLeft(layer)
ViewportRight(layer)
ViewportTop(layer)
B
21
S
9
Posts: 298
Reputation: 2,972

» Mon Jan 26, 2015 3:06 pm

Ribis wrote:
marcel1980 wrote:Hi all,

is there a way to determine if my character is on the left or right edge of the visible screen? I want to limit his movement based on the screen device. I dont want the character to go off the screen since there is no scroll on him. Something like bound by screen would be ideal

there is a behavior https://www.scirra.com/manual/89/bound-to-layout

if you want to use another way, you can make 4 invisible wall and set x,y, and use:

ViewportBottom(layer)
ViewportLeft(layer)
ViewportRight(layer)
ViewportTop(layer)

Bound to layout would be ideal but since there is no scrolling on my main character, it ends like this: my character leaves screen and then game over. The invisible wall could work. Also i thought about restrict his x y movements but on different screen sizes/aspects the character could not reach the edge of screen or go beyond it.
B
8
S
4
G
1
Posts: 191
Reputation: 1,878