Search code examples
backgroundlive-wallpaperrajawali

Create moving background in live wallpaper using rajawali


I'm creating a live wallpaper using rajawali. I load an object on it (with this code: Rajawali object rotation match to camera) and now I want to set moving image in background for it. Has anyone advice for me?


Solution

  • I created Plane:

            mPlane1 = new Plane();
        Material material1 = new Material();
        try {
            material1.addTexture(new Texture("cloud2", R.drawable.cloud2));
        } catch (TextureException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        material1.setColorInfluence(0);
        mPlane1.setMaterial(material1);
        mPlane1.setRotY(180);
        mPlane1.setTransparent(true);
        mPlane1.setPosition(Vector3.X);
        mPlane1.setPosition(-1.6f, 1.2, 1.6);
        getCurrentScene().addChild(mPlane1);
    

    and translate it with TranslateAnimation3D:

    plane1Anim = new TranslateAnimation3D(Vector3.X);
        plane1Anim.setRepeatMode(RepeatMode.INFINITE);
        plane1Anim.setTransformable3D(mPlane1);
        plane1Anim.setDuration(16000);
        getCurrentScene().registerAnimation(plane1Anim);
        plane1Anim.play();