Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example Function for getting the Screen Position. This is directly from the Flixel Code Base.
* Call this function to figure out the on-screen position of the object.
* @param Point Takes a `FlxPoint` object and assigns the post-scrolled X and Y values of this object to it.
* @param Camera Specify which game camera you want.
* If `null`, it will just grab the first global camera.
* @return The Point you passed in, or a new Point if you didn't pass one,
* containing the screen X and Y position of this object.
public function getScreenPosition(?point:FlxPoint, ?Camera:FlxCamera):FlxPoint
if (point == null)
point = FlxPoint.get();
if (Camera == null)
Camera =;
point.set(x, y);
if (pixelPerfectPosition)
return point.subtract(Camera.scroll.x * scrollFactor.x, Camera.scroll.y * scrollFactor.y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment