i'm new both swift , ios development.
i have been working on game based off apple's spritekit (with gameplaykit integration) template.
all working fine until renamed gamescene.swift , gamescene.sks mapmainscene.swift , mapmainscene.sks. made sure change code in gameviewcontroller.swift:
override func viewdidload() { super.viewdidload() // load 'gamescene.sks' gkscene. provides gameplay related content // including entities , graphs. if let scene = gkscene(filenamed: "gamescene") { // skscene loaded gkscene if let scenenode = scene.rootnode as! gamescene? { // copy gameplay related content on scene scenenode.entities = scene.entities scenenode.graphs = scene.graphs // set scale mode scale fit window scenenode.scalemode = .aspectfill // present scene if let view = self.view as! skview? { view.presentscene(scenenode) view.ignoressiblingorder = true view.showsfps = true view.showsnodecount = true } } } }
to:
override func viewdidload() { super.viewdidload() // load 'mainmapscene.sks' gkscene. provides gameplay related content // including entities , graphs. if let scene = gkscene(filenamed: "mainmapscene") { // skscene loaded gkscene if let scenenode = scene.rootnode as! mainmapscene? { // copy gameplay related content on scene scenenode.entities = scene.entities scenenode.graphs = scene.graphs // set scale mode scale fit window scenenode.scalemode = .aspectfill // present scene if let view = self.view as! skview? { view.presentscene(scenenode) view.ignoressiblingorder = true view.showsfps = true view.showsnodecount = true } } } }
i changed following in gamescene.swift
:
class gamescene: skscene { // code }
to in mainmapscene.swift
:
class mainmapscene: skscene { // code }
but app crashes upon launch. output of console says:
2016-07-21 16:29:35.593592 mygame[10656:1944648] [user defaults] cfprefsplistsource<0x6080000e5e00> (domain: kcfpreferencesanyapplication, user: kcfpreferencescurrentuser, byhost: no, container: (null)) waiting writes complete can determine if new data available 2016-07-21 16:29:35.603729 mygame[10656:1944648] [fenceworkspace] creating ca fence port (5d13) 2016-07-21 16:29:35.638 mygame[10656:1944648] *** terminating app due uncaught exception 'nsinvalidunarchiveoperationexception', reason: '*** -[nskeyedunarchiver decodeobjectforkey:]: cannot decode object of class (gamescene) key (root); class may defined in source code or library not linked' *** first throw call stack:
so looks there still reference gamescene
somewhere in project have done project-wide search , there no gamescene
anywhere found.
i'm sure straightforwards. need change outlet or in storyboard editor?? can reproduce problem trying change name of gamescene
in new project know it's not specific project.
gamescene
referenced in 1 more place, , error coming nskeyedarchiver
should clue in where: it's encoded in .sks
file you're loading. can find in "custom class" tab of .sks
file in xcode's editor.
this setting tells nskeyedunarchiver
class encoded scene should when load .sks
file. should last remaining reference gamescene
, should complete renaming!
Comments
Post a Comment