2

I have made a simple live wallpaper in Andengine. In it, I have used a timerHanlder which is rotating the circle. But the problem is when I use it as the live wallpaper the timerhandler does not work and the sprite is static(not rotating) on scene. Here is the code. I cant't firgure out what the problem might be. Please help me.

{     
    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 {

    }
   }
}

  }
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
Usman Iftakhar
  • 278
  • 5
  • 17
  • 1
    solved the problem :) when i registered the updatehandler with the sprite it works perfectly.. but stil dont know why its not working when i register the upadatehandler with scene it does not work. – Usman Iftakhar Oct 02 '12 at 04:49

0 Answers0