How do I BoundToWindow (not BoundToLayout) on all devices

Get help using Construct 2

Post » Thu Jun 25, 2015 2:46 am

I am implementing the Multiple Screensizes tutorial (link below) and have extra padding outside the window to the left and right. I also scroll to the middle on X axis on start to work for most screen ratios, but the issue I have is that I need objects to stay inside the window and not bound to the layout.

Right now, the player (bound to layout) is running off the screen because my layout is 900 wide, but only 720 wide window. How do I make it so that he's bound to the window edges? Do I need to detect each X of the window with WindowWidth? If so, how do I make it dynamic depending on what device they are on?

Multiple screen size tutorial:
https://www.scirra.com/tutorials/1126/multiple-screen-sizing-for-all-mobile-devices
Check out my games on Google Play:

BEAST ATTACK (960,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
50
S
15
G
2
Posts: 427
Reputation: 5,164

Post » Thu Jun 25, 2015 6:52 am

Probably the easiest way would be to clamp the players x-coordinate

system every tick:
player set x - clamp(player.x,viewportleft(0),viewportright(0))

0 is the layer from which the x coordinates are taken.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jun 26, 2015 1:43 am

@LittleStain That works really well! Thank you.
Check out my games on Google Play:

BEAST ATTACK (960,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
50
S
15
G
2
Posts: 427
Reputation: 5,164


Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 8 guests