I need help to understand what I am doing wrong. I am setting a PNG Image as my background (canvas) and then I want to put another PNG image on top at a particular coordinate. But problem is when I set the background canvas PNG first it stays there but when the other image (on top) loads , the background canvas disappear. So obviously I am not doing something right.
Any suggestion from the android developers community would be highly appreciated.
THANKS!
HERE IS THE CODE BELOW:
StartNewGame.java:
package com.firm.armouredassault;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
public class StartNewGame extends Activity {
MyGame ourView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
ourView = new MyGame(this);
setContentView(ourView);
}
}
Mygame.java
package com.firm.armouredassault;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.View;
public class MyGame extends View {
Bitmap BTank, TShell;
public MyGame(Context context) {
super(context);
// TODO Auto-generated constructor stub
BTank = BitmapFactory.decodeResource(getResources(), R.drawable.bluetanksm);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawBitmap(BTank, 10, 200, null);
}
}
newgame.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/canvas"
android:orientation="vertical" >
</LinearLayout>