Frage

My app uses RenderTexture begin(), visit(), end() methods to draw on a canvas(a render texture). Now, how do I implement Undo feature for 1-5-steps.

In my game update loop, Calculate touch and prev touchlocations in the node space, and the distance between them, and draw the line on the canvas by visiting the brush node.

I did have a look at slipster216' reply on : here

But, this approach will probably mean, writing again from the start, as it needs custom stroke class.

Ideas :

  1. Save state of render texture someHOW ?

  2. Save images on touchended and read them on undo on to the sprite, someHOW ?

  3. Keep '5' render texture in the memory, to be replaced while un-do, but heavy on memory ?

Any help is appreciated.

War es hilfreich?

Lösung

Take a temporary buffer of 5 sprites. Each time the user draws something, store it first in the temporary buffer like a queue. At the 6th draw, send the first element to the permanent render texture. For undo, simply delete the queue.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top