0

I am currently setting up a scene using AndEngine GLES2 Center and I have the following doubt: I placed a background and from what I understood, with this new version of AndEngine, the position of a sprite should be relative to the bottom-left.

But if I want to place an object in position (x,y) and I see such position in an editor like FireWorks and usit in the Sprite argument, it will not appear in the same place as appearing in the editor. How to know the correct position to place the object?

thanks!

Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69
pinker
  • 1,283
  • 2
  • 15
  • 32
  • You are right, anchor center uses coordinates from bottom left, but I guess position in FireWorks is a bit off from the phone resolution. So might want to check the canvas size on FireWorks as well as andengine – kabuto178 Oct 31 '13 at 17:14
  • but do you have any recommendations how to position an object in a specific position? how to guess that position? doing different tests? – pinker Oct 31 '13 at 17:18
  • 1
    I use the original GLES2 branch and for positioning I would say just start from 0,0 and make changes until you get where you want then you can use previous coordinates as reference points. I do my positioning in code never used another editor like FireWorks. – kabuto178 Oct 31 '13 at 17:21

1 Answers1

6

Every Sprite (actually Entity) has an anchor point. When you place a Sprite on Scene position (x, y), it means you stick the anchor point of Sprite on the coordinates (x, y).

In AndEngine GLES2 and GLES2-AC branches, both anchor point and coordinates system are different.

             |  GLES2                    |  GLES2-AnchorCenter
-------------+---------------------------+-------------------------------------
anchor point | At corner of entity.      | As branch name, at center of entity.
             | (left-top corner)         | (vertically and horizontally)
             |                           |
             |   anchor point            |
             |   |                       |
             |   V                       |      +-------------+
             |   X-------------+         |      |             |
             |   |             |         |      |      X <-------- anchor point
             |   | I am Entity |         |      | I am Entity |
             |   |             |         |      +-------------+
             |   +-------------+         |
             |                           |
-------------+---------------------------+-------------------------------------
coordinates  | Origin at left-top.       | Origin at left-bottom
             | move right -> x increase, | move right -> x increase,
             | move up -> y decrease.    | move up -> y increase.

Note: The anchor point is also used when Entity rotates, skews and scales. So, in GLES2 branch, when entity is rotating, people often think the entity is also moving, but it doesn't, the anchor point is always fixed at coordinates (x, y).

正宗白布鞋
  • 929
  • 6
  • 13