2
당신이 추천하는 소리를 제어하는 cocos2d 슬라이더를 만드는 방법에 대한 자습서가 있습니까? 자습서 중 일부는 조금 그늘 보입니다.cocos2d의 사운드 슬라이더?
당신이 추천하는 소리를 제어하는 cocos2d 슬라이더를 만드는 방법에 대한 자습서가 있습니까? 자습서 중 일부는 조금 그늘 보입니다.cocos2d의 사운드 슬라이더?
CCControlExtension에 의해 제공되는 슬라이더를 사용하고 콜백 메서드를 사용하여 사운드 볼륨을 here과 같이 변경할 수 있습니다. 여기
는 "의사"코드
이를 달성하는 방법을 보여 :// Create your audio engine
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"music.mp3"];
// Create the slider
CCControlSlider *slider = [CCControlSlider sliderWithBackgroundFile:@"sliderTrack.png" progressFile:@"sliderProgress.png" thumbFile:@"sliderThumb.png"];
slider.minimumValue = 0.0f; // Sets the min value of range
slider.maximumValue = 1.0f; // Sets the max value of range
// When the value of the slider will change, the given selector will be call
[slider addTarget:self action:@selector(valueChanged:) forControlEvents:CCControlEventValueChanged];
[self addChild:slider];
//...
- (void)valueChanged:(CCControlSlider *)sender
{
// Change volume of your sounds
[[SimpleAudioEngine sharedEngine] setEffectsVolume:sender.value];
[[SimpleAudioEngine sharedEngine] setBackgroundMusicVolume:sender.value];
}
내가 당신을 도와 바랍니다.
고맙습니다. 특정 위치에두기위한 제안이 있습니까? 내가 rect를 사용하는 것에 대해 생각하고 있었지만 더 효율적인 방법이 있는지 모르겠다. –
위치에 따라 무엇을 의미합니까? 그 위치를 지정하려면 slider.position 속성을 사용해야합니다. –
이 답변을 주셔서 감사합니다 ... – Guru