The Cccontrolpotentiometer is a potentiometer button, similar to the Cccontrolslider usage. For some configuration of control usage, see article: UI development Control class-cccontrolbutton.
BOOL Helloworld::init () {bool BRet = false; do {cc_break_if (!
Cclayer::init ()); Cccontrolpotentiometer parameter is base, progress bar, control button picture Resource Cccontrolpotentiometer * potentiometer = cccontrolpotentiometer::create (
"Potentiometertrack.png", "Potentiometerprogress.png", "potentiometerbutton.png");
Setting the maximum and minimum values and the initial value potentiometer->setmaximumvalue (100.0);
Potentiometer->setminimumvalue (0.0);
Potentiometer->setvalue (50);
Potentiometer->setposition (CCP (240,160));
This->addchild (potentiometer); Add Event Listener potentiometer->addtargetwithactionforcontrolevents (This,cccontrol_selector HelloWorld::valueChanged
), cccontroleventvaluechanged);
BRet = true;
while (0);
return bRet; } void Helloworld::valuechanged (Ccobject * psender,cccontrolevent controlevent) {Cccontrolpotentiometer * potentiomete
R = (Cccontrolpotentiometer *) Psender;
ccstring * string = Ccstring::createwithformat ("%f", Potentiometer->getvalue ());
Cclog (String->getcstring ()); }