How to implement a GameView code inside a class? (in java code for android)

0

I'm new to java and I'm developing a project, I have the following code below:

paint.setColor (Color.rgb (250, 0, 255)); canvas.drawCircle (xa, ya, 10, paint);

What 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 name class "player", how do I implement this GameView code in the player class by example (if I am not mistaken and in the constructor of the class)?

The full draw method code is this:

private void 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 appreciate it.

    
asked by anonymous 06.08.2018 / 01:33

0 answers