I want to save my game progress by saving the player's current status, such as his position on map, HP, mana, current state, etc..
I need help on how to convert the player object to NSdata and store it in NSUserDefaults.
I have the following properties for player, but how do I encode them using NSCoding? Do I have to encode every single property? and how do I encode components?
var spriteComponent: SpriteComponent!
var animationComponent: AnimationComponent!
var playerMoveComponent: PlayerMoveComponent!
var healthComponent: HealthComponent!
var playerAttackComponent: PlayerMeleeAttackComponent!
var roundHouseSwingComponent: RoundHouseSwingComponent!
var playerMagicAttackComponent: PlayerMagicAttackComponent!
var attackBodyNode: SKNode!
var dashDistance = GameSettings.playerDashDistance
var agent: GKAgent!
var health: Int!
var fullHealth: Int!
var mana: Int!
var fullMana: Int!
var action: Int!
var fullAction: Int!
var hasGateKey: Bool!
var numberOfPotionCarried: Int!
var playerState: PlayerState!
var movementEnabled: Bool!
var dashAttackActivated: Bool!
Thanks for any help in advance.