SurfaceView Inhalt entfernen

S

Skolleus

Neues Mitglied
0
Ich habe ein Problem beim Zeichnen auf einer SurfaceView.
Wie in der Referenz beschrieben*, wird alles, was in der entsprechenden Methode gezeichnet wird, nur zum Bild hinzugefügt. Nichts wird davon entfernt.
Code:
Path line = new Path();

public void doDraw(Canvas canvas){
     canvas.drawPath(line, paint);
}
Werden hier die Werte von 'line' verändert, ergeben sich damit ganz viele Linien im Display statt einer die sich "bewegt".
Allerdings steht dort auch*, dass man das mit einem drawColor() oder dem Setzen eines Hintergrundbildes mit drawBitmap() verhindern könnte.
Mein Code sieht sowieso ein Hintergrundbild vor. Also:
Code:
Path line = new Path();

public void doDraw(Canvas canvas){
      canvas.drawBitmap(mBackground, 0, 0, null);
      canvas.drawPath(line, paint);
}
Das funktioniert aber nicht. Die Linien des letzten Aufrufs werden noch immer beibehalten.
Auch die Idee mit
Code:
canvas.drawColor(color.BLACK);
habe ich erfolglos versucht. Was mache ich falsch?

*
On each pass you retrieve the Canvas from the SurfaceHolder, the previous state of the Canvas will be retained. In order to properly animate your graphics, you must re-paint the entire surface. For example, you can clear the previous state of the Canvas by filling in a color with drawColor() or setting a background image with drawBitmap(). Otherwise, you will see traces of the drawings you previously performed.
 
Zuletzt bearbeitet:
Ok hat sich erledigt.. keine ahung warum ich Path benutze.. drawLine() wäre richtig gewesen. :rolleyes:
 

Ähnliche Themen

Jansenwilson
Antworten
1
Aufrufe
691
Mazuch
Mazuch
M
Antworten
2
Aufrufe
864
jogimuc
J
A
Antworten
4
Aufrufe
1.543
jogimuc
J
Zurück
Oben Unten