4

When I create a sprite at (0,0) and it is centered on the screen and I ask the camera what it's center is (getCenterX and getCenterY) it says (640,400).

I am pretty new with Andengine so there's clearly something basic about coordinates that I am not understanding.

halfer
  • 19,824
  • 17
  • 99
  • 186
pitosalas
  • 10,286
  • 12
  • 72
  • 120

2 Answers2

3

Note that the accepted version is is not valid anymore. Now, AndEngine coordinates have changed to the bottom-left corner of the screen, like cocos-2d.

dwbrito
  • 5,194
  • 5
  • 32
  • 48
2

If you're using the default camera, a Sprite placed at 0,0 would be at the top-left corner of the screen. If you've moved the camera, 0,0 could be at the 'centre' of the screen of course.

Note: Scaling a sprite causes it to shrink towards it's centre (not it's top-left corner) - so a Sprite which is the whole size of the screen will appear in the centre when scaled-down (rather than shrink up into the top-left corner)

  • Thank you! And what about the proportions? What are the default 'units' of each? Am I correct that if the camera's zoom is 1.0 then one unit of sprite corresponds to one pixel? – pitosalas Oct 03 '11 at 21:50
  • 2
    They're one pixel of your chosen CAMERA_WIDTH and HEIGHT. Bear in mind that this will be resized onto different devices depending on their screen size and so won't actually be a real screen pixel on any device which doesn't match your chosen dimensions exactly. For example - if you chose 480x800 it would be resized onto a 320x480 as 289/480 (from a 1.6 ratio to a 1.5) –  Oct 03 '11 at 22:59