Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set anchor point for the sprite like cocos2d has done for their implementation. I do not found any thing like that in andengine so please provide guidance on that. I want to move the sprite on touch so I use following code but that does not work for me.

super.setPosition(pX - this.getWidthScaled() / 2,
            pY - this.getHeightScaled() / 2);

Because I touch on the corner of the image but automatically it comes at center of the image because of above code. I want to remain the touch at desire position and drag it. For me the anchor point became useful. But I don't found anything in andengine.

share|improve this question
On a unrelated note: If your setPosition is not different in your derived class then calling super is pointless. Harmless, but pointless. – Sidar Jun 25 '13 at 7:45

This is pretty basic, you need to remember the distance from the center when you first touch the Sprite and then take this into account when moving it around.

share|improve this answer

Not sure if this is what you want, because I don't know cocos2d. Entity in AndEngine has method:

public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
    return false;

The pTouchAreaLocalX and pTouchAreaLocalY will give you relative position of touch inside the entity and pSceneTouchEvent then contains the absolute position on screen. You can use the local coordinates to correct the position.

share|improve this answer

Your Answer


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.