我在Andengine做了一个简单的动态壁纸。在其中,我使用了旋转圆圈的timerHanlder
。但问题是当我将它用作动态壁纸时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 {
}
}
}
}