Entity screen position/coordinates


(André Perdigão) #1

I have a camera following a player and the camera is not fixed to the player position. I need to get an entity screen coordinates and not world coordinates. How can i do that?


(Jacob Albano) #2
var screenX:Number = entity.x - FP.camera.x;
var screenY:Number = entity.y - FP.camera.y;

(Ultima2876) #3

I haven’t done a lot of messing with camera stuff. My first instinct was that it’d be entity.x - FP.camera.x and entity.y - FP.camera.y?


(Jacob Albano) #4

You are completely right. I’ll edit my original comment.


(André Perdigão) #5

Thanks guys, it was really simple x)


(Ultima2876) #6

I was assuming I was wrong and that it’d be something I hadn’t taken into account like the Camera scrolling negatively or something. FP still has a few gotchas like that! (see the layering system for one…) :slight_smile:


(Zachary Lewis) #7

Just think of it as “a graphic’s layer is the distance away from the camera.”

If you can’t handle that, ya’ turkey, make a helper function.

public static function getLayer(value:int):int
{
  return -1 * value;
}

:stuck_out_tongue_winking_eye:


(Ultima2876) #8

Yeah, it’s more the naming scheme that threw me off initially (and probably does so to quite a few people). If it was called ‘depth’, I’d be all over it ;D

I’ve totally gotten used to just using negative layers now anyway.