tags:

views:

188

answers:

1

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

A: 

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