Update extensions/GUI/CCControlExtension/CCControlSwitch.cpp

implement setOn(isOn,false)
This commit is contained in:
xyhl515 2013-01-31 22:12:37 +08:00
parent 9b5d0bd251
commit 3316f8c961
1 changed files with 16 additions and 11 deletions

View File

@ -345,17 +345,22 @@ void CCControlSwitch::setOn(bool isOn)
void CCControlSwitch::setOn(bool isOn, bool animated) void CCControlSwitch::setOn(bool isOn, bool animated)
{ {
m_bOn = isOn; m_bOn = isOn;
m_pSwitchSprite->runAction if (animated) {
( m_pSwitchSprite->runAction
CCActionTween::create (
( CCActionTween::create
0.2f, (
"sliderXPosition", 0.2f,
m_pSwitchSprite->getSliderXPosition(), "sliderXPosition",
(m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition() m_pSwitchSprite->getSliderXPosition(),
) (m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition()
); )
);
}
else {
m_pSwitchSprite->setSliderXPosition((m_bOn) ? m_pSwitchSprite->getOnPosition() : m_pSwitchSprite->getOffPosition());
}
sendActionsForControlEvents(CCControlEventValueChanged); sendActionsForControlEvents(CCControlEventValueChanged);
} }