我有一个用于更改游戏场景的按钮,我把它放在 CCSCrollLayer 中,它停止工作,这是我的代码:
// create a blank layer for page 1
CCLayer *pageOne = [[CCLayer alloc] init];
// create a button for page 1
CCMenuItem *level1 = [CCMenuItemImage
itemFromNormalImage:@"level_skatepark_icon.png" selectedImage:nil
target:self selector:@selector(level1Tapped:)];
level1.position = ccp(winSize.width/2, winSize.height/2 - 28);
// add button to page 1 layer
[pageOne addChild:level1];
// now create the scroller and pass-in the pages (set widthOffset to 0 for fullscreen pages)
CCScrollLayer *scroller = [[CCScrollLayer alloc] initWithLayers:[NSMutableArray arrayWithObjects: pageOne,pageTwo,pageThree,pageFour,nil] widthOffset: 150];
// finally add the scroller to your scene
[self addChild:scroller];
听者:
- (void)level1Tapped:(id)sender {
//Goto level SkatePark!
[[CCDirector sharedDirector] replaceScene:[HelloWorldLayer scene]];
}
谁能帮我?