Developing a little game

Developing a little game

I am trying to make a game.

I am trying to make a game.

I have a mainActivity which is called BridgeScene here and I create a class for the ennemy

In the mainActivity, I have two ImageView and some button!

In my class, I have an ennemy (represented by a Rectangle) and I use Canvas to draw a Rectangle. What I need to is to draw this Rectangle on my BridgeScene Activity. How can I do that?

I cannot set the contentview twice because it is already set in the activity as setContentView(R.layout.activity_bridge_scene);

So how can I draw my rectangle from my class ennemy in my BridgeScene activity?

My activity:

public class BridgeScene extends AppCompatActivity {

private static final  int[] ALL_DRAWABLE_RES_EAGLE = new int[]{

private Ennemy1 ennemy1;

private Handler handler = new Handler();
private final static long Interval = 30;

private Runnable updateImageTask;
private int currentDrawableResIndex;

private static long IMAGE_UPDATE_DELAY_MILLIS = 30;

private ImageView imvStickman;
private ImageView imvJump;

protected void onCreate(Bundle savedInstanceState) {

    ennemy1 = new Ennemy1(this);

    updateImageTask = new UpdateImageTask();

    imvJump = (ImageView) findViewById(;

    imvStickman = (ImageView) findViewById(;
    imvEnnemi = (ImageView) findViewById(;

    imvJump.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {


My class:

public class Ennemy1 extends View{
    public  Bitmap rec;
    public  int recX;
    public  int recY;

public int canvasWidth;
public int canvasHeight;

public Ennemy1(Context context){
    rec = BitmapFactory.decodeResource(getResources(), R.drawable.enem1);

protected void onDraw(Canvas canvas) {
    canvas.drawBitmap(rec, 100, 100, null);
    canvasWidth = canvas.getWidth();
    canvasHeight = canvas.getHeight();


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Android App Development Company in UAE

Have a plan to build an robust Android App Development with multiple features? We at Data EximIT is one of the best **[Android App Development Company in UAE]( "Android App Development...