Cocos2d iphone cocos2d中的滑块
如何在cocos2d层上添加滑块,即直接在GameSecene上添加滑块。m???您不能将UISlider作为cocos2d节点直接添加到层/场景中 您必须将其作为子视图添加到cocos2d图层。以下是一个例子:Cocos2d iphone cocos2d中的滑块,cocos2d-iphone,slider,Cocos2d Iphone,Slider,如何在cocos2d层上添加滑块,即直接在GameSecene上添加滑块。m???您不能将UISlider作为cocos2d节点直接添加到层/场景中 您必须将其作为子视图添加到cocos2d图层。以下是一个例子: UISlider *sliderCtl = [[UISlider alloc] initWithFrame:CGRectMake(170, 0, 125, 50)]; [sliderCtl addTarget:self action:@selector(sliderActio
UISlider *sliderCtl = [[UISlider alloc]
initWithFrame:CGRectMake(170, 0, 125, 50)];
[sliderCtl addTarget:self action:@selector(sliderAction:)
forControlEvents:UIControlEventValueChanged];
sliderCtl.backgroundColor = [UIColor clearColor];
sliderCtl.value = 0;
[[[[CCDirector sharedDirector] openGLView] window]
addSubview:sliderCtl];
对于cocos2d的更高版本,在下面的语句中不需要窗口。它支持自动旋转 [[[CCDirector sharedDirector]openGLView]addSubview:sliderCtl]