★ TouchArcade needs your help. Click here to support us on Patreon.

Spritekit undo move

06-21-2014, 12:42 PM
#1
Spritekit undo move

Anyone familiar with spritekit?
Can some one tell me how we can keep a track of user moves? And how to add an undo move feature in spritekit?

Been looking all over the internet for this but no luck.
06-21-2014, 05:36 PM
#2
Quote:
Originally Posted by Prashant View Post
Anyone familiar with spritekit?
Can some one tell me how we can keep a track of user moves? And how to add an undo move feature in spritekit?

Been looking all over the internet for this but no luck.
Check out gameprogrammingpatterns.com - very useful book.
You need a "Command" design pattern.
Basically you create an object for every move and send it to your control code. Each command can also have equivalent undo object as either field in itself, or a separate object.

So this way when you want to undo you just tell your control code to execute undo on last command.