Just started with coco2d/swift and am having trouble presenting a scene. I created a new one in spritebuilder, published it, and am loading it with CCReader as a scene. When I try to present it, it won't present.
class MainScene: CCNode {
override init(){
super.init()
let mainMenu = CCBReader.loadAsScene("ccbResources/MainMenu");
CCDirector.presentScene(mainMenu)
}
}
I get a build error saying:
"cannot invoke presentScene with an argument list of type CCScene".
So I can't really find any examples of this working for me or how to do it.
Only once you can use presentScene, then try replaceScene
class GameScene: CCScene {
class func scene() -> GameScene
{
return GameScene()
}
override init()
{
super.init()
}
}
class MainScene: CCScene {
class func scene() -> MainScene
{
return MainScene()
}
override init()
{
super.init()
//to replace scene
CCDirector.sharedDirector().replaceScene(GameScene.scene())
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.