Skip to content
Permalink
Browse files

Animate the ammo.

  • Loading branch information
avh4 committed Jan 15, 2013
1 parent 964b6d7 commit b6521d50f7c2d65bab20ac9e98fb41a001187e7d
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/com/example/ScorchedPocket/ScorchedPocketGame.java
@@ -2,14 +2,17 @@

import android.content.Context;
import android.graphics.*;
import android.os.Handler;
import android.view.View;

public class ScorchedPocketGame extends View {
public class ScorchedPocketGame extends View implements Runnable {
Bitmap backgroundImage;
Bitmap tank1Image;
Bitmap tank2Image;
Bitmap ammoImage;
Bitmap explosionImage;
Handler handler = new Handler();
private int ammoX = 85;

public ScorchedPocketGame(Context context) {
super(context);
@@ -24,6 +27,8 @@ public ScorchedPocketGame(Context context) {
R.drawable.ammo1);
explosionImage = BitmapFactory.decodeResource(getResources(),
R.drawable.explosion);

handler.postDelayed(this, 30);
}

@Override
@@ -32,7 +37,15 @@ protected void onDraw(Canvas canvas) {

canvas.drawBitmap(tank1Image, 11, 226, null);
canvas.drawBitmap(tank2Image, 404, 268, null);
canvas.drawBitmap(ammoImage, 85, 203, null);
canvas.drawBitmap(ammoImage, ammoX, 203, null);
canvas.drawBitmap(explosionImage, 155, 164, null);
}

@Override
public void run() {
ammoX = ammoX + 5;

postInvalidate();
handler.postDelayed(this, 30);
}
}

0 comments on commit b6521d5

Please sign in to comment.
You can’t perform that action at this time.