本文介绍了如何在andengine中注销移动修饰符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在sprite上使用了move修饰符,但是当我将背景以及该sprite移出屏幕时,它会自动在屏幕上重新显示如何取消注册

i used move modifier on sprite but when i move background and also that sprite out of the screen it automatically comes back on the screen how i unregistered it

LoopEntityModifier bucket2 =
    new LoopEntityModifier(new SequenceEntityModifier(
        new MoveModifier(1.5f, 0, 290.9f,270.0f , 210.0f),
        new MoveModifier(1.5f, 290.9f,0,220.0f , 270.0f))); // // new ScaleModifier(2.0f, 1.0f, 0.0f)
    buckt[2].registerEntityModifier(bucket2);

注意:我使用此代码取消注册,但没有取消注册

Note: I used this code to unregister but it does not unregister

buckt[2].unregisterEntityModifier(bucket2);

推荐答案

在这里我们看到您使用LoopModifier.因此,在此内部,所有修饰符都会重复运行,因为您没有设置循环号.要运行一次,请编写如下代码:

Here we saw you use LoopModifier. So, inside this, all modifier runs reapeatedly because you don't set the loop number. To run once write code like:

LoopEntityModifier bucket2 =
new LoopEntityModifier(new SequenceEntityModifier(
    new MoveModifier(1.5f, 0, 290.9f,270.0f , 210.0f),
    new MoveModifier(1.5f, 290.9f,0,220.0f , 270.0f)),1);

此处是要分配的值,循环运行多少次.

要单独注销修改器,您需要在修改器中单独实现侦听器.像

To unregister a Modifier individually , you need to implements listener in the modifier individually. Like

全局声明一个修饰符.然后用它实现侦听器.

Declare a Modifier Globally. Then implements listener with it.

private MoveModifier aTestModifier;
    public void test() {

     aTestModifier = new MoveModifier(2f, 10, 100, 50, 50,
            new IEntityModifierListener() {

                @Override
                public void onModifierStarted(IModifier<IEntity> pModifier,
                        IEntity pItem) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onModifierFinished(
                        IModifier<IEntity> pModifier, IEntity pItem) {
                    // unregister your modifier
                    unregisterEntityModifier(aTestModifier);

                    // same for all other modifier
                }
            });
}

与所有其他修饰符相同. :)

same for all other modifier. :)

这篇关于如何在andengine中注销移动修饰符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:55