How to get the distance between the edge of the screen and a vector moving sprite? I want to get the distance between my moving sprite and the edge of the screen so that when my sprite touches the edge it will bounce of. I am using LIBGDX to develop a game. It uses java language.
This can easily be done just with the bounds of the screen and the position of the sprite. The screen bounds can be stored in two variables,
So you can find out if it's touching an edge like this (this is not copy/paste code, find the appropriate methods/members for your environment):