ios - Gamescene.sks and GameScene.swift don't seem to be linked in my project -
i learning spritekit , started small project using level editor.
however, gamescene.swift , gamescene.sks don't seem linked reason. below screenshots .sks file setup , small print statement in viewdidload of .swift file. please let me know doing wrong. or if missing something.
the spritekit .sks file.
my view controller's viewdidload function.
class gameviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() let screensize = cgsize(width: uiscreen.main.bounds.width, height: uiscreen.main.bounds.height) gamecontroller.gamecontroller.setgamemanager(gameviewmanager: self); if let view = self.view as! skview? { // load skscene 'gamescene.sks' if let scene = skscene(filenamed: "gamescene") { // set scale mode scale fit window scene.scalemode = .aspectfill // present scene view.presentscene(scene) } } }
we have normal gamescene.swift
should print "hello" gamescene.sks
called gameviewcontroller
. did not specify gamecontroller
not problem because think lost flow of game try (dont' worry, happens when focused on rest of game long time , can not remember starting flow).
in main.storyboard
don't have situation this:
where gameviewcontroller
is initial view controller. mean should check call gameviewcontroller
on storyboard or if appdelegate.swift
(in didfinishlaunchingwithoptions
) stop flow or call other views before calling gameviewcontroller
.
so , check ivc (initial view controller) , sure gameviewcontroller
called start or other viewcontrollers using breakpoint or launch print in viewdidload
:
print("∙ \(type(of: self))")
another situation happen when add or remove files same name in library. in case try remove gamescene.swift
, gamescene.sks
, clean , build project , re-add these files (be sure screen gamescene.sks have right custom class..) check compile sources list control gamescene.swift
hope helps.
Comments
Post a Comment