2011-07-25 25 views
0

切換場景下面是我知道改變的場景的cocos2d代碼:與輸入

[[CCDirector sharedDirector] replaceScene:[HelloWorld scene]]; 

但我不知道是否有可能,我可以用一些參數切換的場景。 這個方法我試過:

HelloWorld *scene = [HelloWorld scene]; 
[scene initWithInput:0]; 
[[CCDirector sharedDirector] replaceScene:scene]; 

- (空)initWithInput:(INT)輸入是我寫在HelloWorld類測試。

而且它不工作,有人知道如何去做嗎?

回答

1

嘗試覆蓋現場方法。像

+(id) sceneWithInput:(int) i 
{ 
// 'scene' is an autorelease object. 
CCScene *scene = [CCScene node]; 

// 'layer' is an autorelease object. 
HelloWorld *layer = [HelloWorld nodeWithInput:i]; 

// add layer as a child to scene 
[scene addChild: layer]; 

// return the scene 
return scene; 
} 

的東西,那麼你會打電話 [CCDirector sharedDirector] replaceScene:HelloWorld的sceneWithInput:0];

+0

謝謝,就像我剛剛發現的那樣,它的功能就像一個魅力。 – james