Constrain actor to top and bottom of device screen

bkhoward2001bkhoward2001 Member, PRO Posts: 86

I have an actor that using keyboard controls can go up and down... i don't want it to be able to go outside of the top or bottom of the given screen. How do I do this? Thanks.

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Wrap your keyboard controls in a Rule that will check for the actors Y location and only allow movement when it's within the screen bounds.

  • bkhoward2001bkhoward2001 Member, PRO Posts: 86

    But what happens since each device will have it's own dimensions?

  • JapsterJapster Member Posts: 672
    edited March 2018

    @bkhoward2001 said:
    But what happens since each device will have it's own dimensions?

    Don't confuse yourself worrying about that, just follow @jamie_c 's advice, as Gamesalad output is controlled by the CAMERA size - ie. it doesn't matter if you're on a low-res device or a high-res one, eg - 3/4 across the screen will be the same on both, your camera view is re-sized by GS to the device screen resolution/limits.

    So don't worry about the raw co-ordinates on the device's screen, just go by your own 'set' scene / camera size in your game, and use that as the limiting value. :smile:

    Of course, if you're scrolling along a level, you'd need to add some logic to limit movement to the extremities of the camera's current position/size, but I'm assuming you maybe don't intend to do this with the game in question?...

    Also, the other nice 'n' easy method to limit movement, which works for both of the above, is to have pinned visible or invisible actors that you can use a bounce/collide behaviour on, to ensure your actors cannot pass these 'barriers'...

Sign In or Register to comment.