I had noticed the AndEngine a few days ago, and I tried to create basic game with a few Sprites.Sure, the engine makes the development process much more easier.However I found the sprite lacking a major functionally:

Whenever there is a need to refer to the position of an Sprite the engine manipulates the position based on the top-left corner of sprite,this is not the best thing because there is a need to subtract/add the width/height to its position in order to refer to its center.However when we refer to he scale of the Sprite it scaled according to its center point (which is great)

I find it very confusing to refer to its position each time differently.I solved that by extending the Sprite class and implementing my methods of setCenter and getCenter, I guess that not the best way to do so.

Do you have any suggestion?

  • \$\begingroup\$ I have not used that engine before, but extending classes is usually a great way to implement specific functionality that you need. What makes you think this is not the best way to do that? \$\endgroup\$ Commented Nov 13, 2012 at 5:58
  • \$\begingroup\$ The class I'm extending right now is a Sprite, there is another class AnimatedSprite,which is an extension of Sprite.adding methods of my own to the Sprite class won't allow me to use the AnimatedSprite unless I create an interface which defines all the methods of my extended sprite and implemented it inside all the original Sprites, which is a mess \$\endgroup\$ Commented Nov 13, 2012 at 17:49
  • \$\begingroup\$ Why do you need to refer to the center anyway? The size of the sprite and location of the sprite are two separate things, you shouldn't think of them as the same. If all sprites are positioned according to the top-left, then they all match. \$\endgroup\$
    – Thraka
    Commented Nov 13, 2012 at 18:47
  • \$\begingroup\$ Sprite are not mathematical vectors, the position and its reference point is very important.Let say there is a jet fighter which is followed by a missile , Do I want the missile to follow the top left corner pf the jet? of course not, It should follow the center of the plane \$\endgroup\$ Commented Nov 13, 2012 at 18:58
  • \$\begingroup\$ You are probably going to have to implement your own animation class anyways. There are many ways of define the "center" of a sprite, and the definition you use is completely up to you. In a previous platform shooter game I made, I had my animation class, and each sprite had two "centers": one "foot point" with which I performed collision detection with the walls, and an "action point" from where bullets would spawn. What I mean is that the actual semantics of "center" may vary widely, and you're probably going to have to implement your own. \$\endgroup\$ Commented Nov 14, 2012 at 2:06

2 Answers 2


I'v decided to completely decouple the logic of the game from the Engine via interfaces.This seems to work quite well and I guess that is the best way (that I found so far) to overcome the drawbacks of this engine.


There's a branch of GLES2 called Anchor-Center. That will allow you to position based on where you set the Anchor-Center.

  • \$\begingroup\$ This answer would be more useful if it explained to the OP how it would help. \$\endgroup\$
    – user1430
    Commented Jan 11, 2013 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .