开发者

Slider in cocos2d [closed]

It's difficult to tell what is b开发者_高级运维eing asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

how to add a slider on cocos2d layer i.e directly on gamescene.m??


you cant add a UISlider directly as a cocos2d node to a layer/scene.

You have to add it as a subview to your cocos2d layer. here is an example:

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];


For the later version of cocos2d, don't need window in following statement. That support autorotation.

[[[CCDirector sharedDirector] openGLView] addSubview:sliderCtl];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜