How to implement Undo and Redo feature in as3

前端 未结 4 1053
悲&欢浪女
悲&欢浪女 2021-01-27 14:33

I am going to create an application in that i have to implement an Undo and Redo feature. In the application there will be multiple objects located on stage and

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-27 15:25

    If you only want two different states (default and "changed"), it should be pretty trivial to implement. Store the new values and the updated values for each object in arrays, and set the positions from the relevant array when you press "undo" or "redo".

    If you need something more complicated, you could store everything you do as an "action" which is undoable. Eg, there is a class (for example "Action") with several child classes ("Move", "ChangeColor" etc). They contain the change they perform (how many pixels we should move) and methods for performing the action (move object X pixels) and undoing the action (move object -X pixels).

提交回复
热议问题