How to implement a Gameview code within a class?(in java code for android)

Asked

Viewed 28 times

0

I am new in java and I am developing a project, I have the following code below:

Paint.setColor(Color.rgb(250, 0, 255)); canvas.drawCircle(Xa, ya, 10, Paint);

Which I use in the Gameview draw method to create circles in my project (a game), I need to create several classes, one of them and the "player" name class, as I do to implement this Gameview code in the player class for example (if I’m not mistaken and in the class builder)?

The complete code of the draw method and this:

void private draw() {

        if (ourHolder.getSurface().isValid()) {
            canvas = ourHolder.lockCanvas();

            paint.setColor(Color.rgb(0,0,0));
            canvas.drawPaint(paint);

            paint.setColor(Color.argb(255, 255, 255, 255));
            paint.setTextSize(30);
            canvas.drawText("PLAY", 250, 250, paint);


            paint.setColor(Color.argb(255, 255, 255, 255));
            paint.setTextSize(30);
            canvas.drawText("SCORE:" + score, 300, 50, paint);


            paint.setColor(Color.rgb(255, 0, 255));
            canvas.drawCircle(xj, yj, 30, paint);

            ourHolder.unlockCanvasAndPost(canvas);
        }
    }

I want to implement it in this part of the player class:

Jogador(Context context) {


}

If anyone can help I’d appreciate it.

  • Try to post a part of the code you already have!

  • I rephrased the question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.