Search code examples
android-studioanimationdraw

Android Studio draw animation


I am making Space Invaders for school project. Right now I want to animate background (so user have feeling that ship is moving forward in space).

I saw here some ideas with activity, but I am using layout from java class and not from layout.

` display.getSize(size);
    spaceInvadersEngine = new SpaceInvadersEngine(this, size.x, size.y);
    setContentView(spaceInvadersEngine);`

In SpaceInvadersEngine I have

  private void draw(){
   
    if (ourHolder.getSurface().isValid()) {
        canvas = ourHolder.lockCanvas();
        canvas.drawBitmap(backgroundImage,0,0,null);

Is there a way to animate this backgroundImage by Y-coordinate using draw() or to draw 2 different bitmaps that will slide and make this moving effect?


Solution

  • If anyone else is stuck on parallax effect for an Android Studio I found all explained here