A
A
Alexander Kolmachikhin2018-09-25 03:57:12
Android
Alexander Kolmachikhin, 2018-09-25 03:57:12

How to connect / superimpose images or “put on” “armor” on a drawn hero?

My task, if you pull it out of the general context of the idea:
A hero is created, all the necessary fields are written to the database.
Where information about the hero is displayed, his picture is also displayed. If the hero has armor or weapons in the database, for example, then they are displayed here as well.
The question is, how do I "put" a sword into the hero's hand or "put on" armor on him? Only this idea comes to mind: take the imageview of the hero, put the imageview of the sword on top and also on top of the imageview of the armor. But this is the last way I would like to solve this problem.
Does anyone have any ideas how to do it correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Nikolaev, 2018-09-25
@Alexander_Kolmachikhin

Create 1 view.
Override onDraw and draw as many bitmaps as you need with the canvas.
PseudoCat.

@Override
public void onDraw(Canvas canvas) {

        Bitmap image = BitmapFactory.decodeResource(getResources(),R.drawable.body);
        canvas.drawBitmap(image, 0, 0, paint);

        // if weapon exist
        Bitmap image2 = BitmapFactory.decodeResource(getResources(),R.drawable.weapon);
        canvas.drawBitmap(image2, 0, 0, paint);

        // if armor exist
        Bitmap image3 = BitmapFactory.decodeResource(getResources(),R.drawable.armor);
        canvas.drawBitmap(image3, 0, 0, paint);
}

G
GavriKos, 2018-09-25
@GavriKos

Use graphics libraries or game engines rather than trying to eat a cactus with an imageview.
PS what kind of fashion has gone ... Some on the unity herat what is written on the native in 3 lines, others are the other way around ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question