setPosition of Sprite onUpdate in AndEngine

Posted by SSH This on Game Development See other posts from Game Development or by SSH This
Published on 2012-12-12T23:14:19Z Indexed on 2012/12/12 23:21 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

I am trying to get a "highlighter" circle to follow around a sprite, but I am having trouble, I thought I could use the onUpdate method that's available to me in SequenceEntityModifier but it's not working for me. Here is my code:

    // make sequence mod with move modifier
    SequenceEntityModifier modifier = new SequenceEntityModifier(myMovemod) {

        @Override
        protected void onModifierFinished(IEntity pItem) {
            // animation finished
            super.onModifierFinished(pItem);
        }

        public float onUpdate(float pSecondsElapsed, IEntity pItem) {

            highlighter.setPosition(player2.getX() - highlighterOffset, player2.getY() - highlighterOffset);
            return pSecondsElapsed;
        } 

    };

When onUpdate is completely commented out, the sprite moves like I want it to, everything is ok. When I put the onUpdate in, the sprite doesn't move at all. I have a feeling that I am overriding the original onUpdate's actions?

Am I going about this the wrong way? I am new to Java, so please feel free to advise if this isn't going to work.

UPDATE: The player2 is the sprite that I'm trying to get the highlighter to follow.

© Game Development or respective owner

Related posts about java

Related posts about android