我製作了一個戰艦遊戲,玩家和計算機輪流在10X10格子上發射炸彈。Cocos2d遊戲兩個場景之間的替換場景
我對iPhone使用cocos2d 2.0。
我有兩個場景,PlayerScene
和AIScene
。
在Playerscene.m,我用
[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInR transitionWithDuration:1.0 scene:[AIScene sceneWithPositions:otherpos andHits:otherhits andOtherPositions: rects andOtherHits: prev]]];
玩家選擇了位置後,推進到AIScene。
這個效果很好。
然而,在AIScene,我採用的是
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[CombatScene sceneWithParameters:OtherPositions andHits:OtherHits andOtherPositions: Positions andOtherHits: Hits]]];
回去,這是行不通的。遊戲保持在AIScene。
但是,我能夠觸摸屏幕,遊戲將閃光我PlayerScene
與我剛剛放置的炸彈,並返回到AIScene
。
出了什麼問題?
最新信息:我在AIscene中添加了一個按鈕來觸發replaceScene事件,它的工作原理。但是,如果我將它添加到onEnter()方法的末尾,它不起作用。
你確定你需要場景替換嗎?在這種情況下似乎很奇怪。 – Morion