Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How can i block sprite to outside screen ?  (Read 1361 times)

0 Members and 1 Guest are viewing this topic.

unkus

  • Newbie
  • *
  • Posts: 1
    • View Profile
How can i block sprite to outside screen ?
« on: October 26, 2018, 09:34:47 am »
How can i block sprite to outside screen ?

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: How can i block sprite to outside screen ?
« Reply #1 on: October 28, 2018, 08:55:01 pm »
Just ask (with an if statement) if your sprite will step outside the screen before making it move, and if it will, then don't move it.
This is, if X is not lower than screen left, if Y is not lower than screen top, if X + WIDTH is not greater than screen left + screen width - 1, and if Y + HEIGHT is not greater that screen top + screen height - 1

If you can be more specific maybe you can get more and better replies