2011-03-10 31 views

回答

1

難道你不能只在應用程序委託的applicationWillEnterForeground:方法中檢查CCDirector的runningScene屬性嗎?如果您繼承CCScene類,則只需檢查場景的類,否則可能需要爲每個場景添加其他類型的標識符。

+0

檢查課程給我一個CCScene,這並沒有真正縮小它。 – willc2 2011-03-11 07:38:04

+0

您可以隨時使用'CCScene'的'tag'屬性,並在創建時給每個場景一個獨特的標籤,然後在'applicationWillEnterForeground:'中檢查運行場景的標籤。 – 2011-03-11 11:04:25

0

你可以添加一個標識符CCSCene類如int sceneIDtypedef enum { mainMenuID = 0, playSceneID, helpSceneID, aboutSceneID } sceneID,然後簡單地分配給每一種在每個場景的init方法......那麼您可以在applicationWillEnterForeground:檢索它像這樣:

int theSceneID = [[[CCDirector sharedDirector] runningScene] classID];

但像Zaid建議的那樣,使用CCScene的標籤更加容易。

相關問題