开发者

Slider in cocos2d [closed]

开发者 https://www.devze.com 2022-12-29 13:06 出处:网络
It's difficult to tell what is b开发者_高级运维eing asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
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

精彩评论

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