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.
How do I implement Undo in a coloring app, which uses RenderTexture
-
01-06-2022 - |
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 :
Save state of render texture someHOW ?
Save images on
touchended
and read them on undo on to the sprite, someHOW ?Keep '5' render texture in the memory, to be replaced while un-do, but heavy on memory ?
Any help is appreciated.
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow