Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Panda Pajama Nov 13 '12 at 5:58
    
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 –  Kirill Kulakov Nov 13 '12 at 17:49
    
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. –  Thraka Nov 13 '12 at 18:47
    
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 –  Kirill Kulakov Nov 13 '12 at 18:58
    
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. –  Panda Pajama Nov 14 '12 at 2:06
show 1 more comment

2 Answers

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

share|improve this answer
    
This answer would be more useful if it explained to the OP how it would help. –  Josh Petrie Jan 11 '13 at 16:34
add comment
up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.