Help me

edited May 2012 in Help request
I'm trying to stop the object moving past screen's border but it fails.Someone help me?
Please! a.PNG
a 35.9K

Comments

  • edited May 2012
    Hi visaodem102 and welcome here!

    I'd be happy to help but there are a few different ways of doing that depending on other constraints you might have for your game.
    If you could post your code/config or at least give more details on what you've tried, it'd be much easier to help you! :)
  • edited May 2012
    Hi again!

    So right now you don't have any body on your ship, which means you don't use the physics at all, not even for collisions.

    The easiest way to limit your ship currently is by doing it manually: after computing its new position and the camera new position, makes sure it's still in the camera frustum (there are accessors for that) and correct the ship position accordingly before applying it.

    If you plan on using physics/bodies for your game later on, I'd suggest not using SetPosition as it'll break any physics contact point every frame. Instead prefer using SetSpeed as it will work much better in that case.

    If you need more details, please let me know!
  • edited May 2012
    Another option for when/if you use bodies would be to attach invisible walls to the camera that will create boundaries limiting the relative movement of your ship. This requires a bit more setup on the config side to get working correctly though, but on the other side won't require any code for handling it. :)
  • edited May 2012
    If you can, please write your code example. :)
  • edited May 2012
    Will do, but probably not before a few days!
Sign In or Register to comment.