我們在xcode中切換spritebuilder中的scene時,一般使用的是如下代碼:
但是實際我們知道mainscene是放在spritebuilder中的mainscen.ccb檔案中的,我們能否在代碼中加字尾調用呢?答案是:不可以!
原文引用如下:
“you should not append the .ccb file extension when loading ccbs. it’s a common and understandable mistake, but ccbreader will fail to load files where you specify the .ccb extension. published ccb files are converted to a binary format optimized for fast loading and compact storage. this binary file format carries the extension .ccbi—that’s .ccb with a trailing i. the plain text format .ccb files aren’t actually in the bundle. therefore, it’s important to omit the file extension in calls to ccbreader. or, perhaps to remind you of the differing extensions, you can also append the .ccbi extension.”
原來spritebuilder中的ccb檔案為了空間和格式的需求實際被轉換為ccbi檔案放在bundle中,這就是原因.
但是我們可以明确加載字尾為ccbi的檔案,這樣是可以的: