2

我在 Andengine 中制作了一个简单的动态壁纸。在其中,我使用了timerHanlder旋转圆圈的 a 。但问题是当我将它用作动态壁纸时,timerhandler它不起作用并且sprite在场景中是静态的(不旋转)。这是代码。我无法弄清楚问题可能是什么。请帮我。

{     
    BitmapTextureAtlas firstCircleAtlas;
    ITextureRegion firstCircleRegion;
    Sprite firstCircle;
    Scene mScene;
    int angle=0;
    @Override
    public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
        firstCircleAtlas=new BitmapTextureAtlas(128,128,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
        this.mEngine.getTextureManager().loadTexture(firstCircleAtlas);
        firstCircleRegion=BitmapTextureAtlasTextureRegionFactory.createFromAsset(firstCircleAtlas, getApplicationContext(), "3.png", 0, 0);
        firstCircle=new Sprite(0,0,firstCircleRegion);
        mScene=new Scene();
        mScene.attachChild(firstCircle);
        mEngine.setScene(mScene);
        firstCircle.setRotation(90);

        mScene.registerUpdateHandler(new TimerHandler(1f, new ITimerCallback() {

            @Override
            public void onTimePassed(TimerHandler pTimerHandler) {
                if(angle==360)
                {
                    angle=0;
                }
                angle++;
                    firstCircle.setRotation(angle);             
            }
        }));
    }

    @Override   
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
            throws Exception {

    }

    @Override
    public void onPopulateScene(Scene pScene,OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {

    }
   }
}

  }
4

0 回答 0