3

I am very new to AndEngine. I found that I can use an Entity on which I applied MoveModifier or for some other Modifiers it may also work. For example:

MoveModifier mm = new MoveModifier(1.0f,startx, starty, endx, endy) {
@Override
protected void onModifierStarted(IEntity pItem) {
        //do somthing with pItem
    }

    @Override
protected void onModifierFinished(IEntity pItem) {
    //do somthing with pItem        
}
};

But I can't do the same thing with IUpdateHandler when I apply it on an Entity (Sprite). So, is there any way so that I can use the Entity (Sprite) from inside the Handler call?

Edit:

What I actually want is something like this:

IUpdateHandler mm = new IUpdateHandler() {
@Override
protected void onModifierStarted(IEntity pItem) {
        //do somthing with pItem
    }

    @Override
protected void onModifierFinished(IEntity pItem) {
    //do somthing with pItem        
}
};

But this doesn't work. Any other way or is there a way to pass anything as the IUpdateHandler parameter?

4

2 回答 2

1

add to your modifier

@Override
protected void onManagedUpdate(float pSecondsElapsed, IEntity pItem) {

    //add your actions

    super.onManagedUpdate(pSecondsElapsed, pItem); 
}
于 2013-06-07T12:17:02.853 回答
0

Actually it is not possible in case of IUpdateHandler to have the entity locally like the MoveModifier. So I had to declare the Entity globally and then use it inside the IUpdateHandler.

于 2013-09-29T19:56:12.283 回答