void ButtonSprite::onReleaseOutside(int x, int y, int button) { if (!BaseSprite::visible || !BaseSprite::worldMouseEnabled || !isInRenderTree()) return; if (default_state->parentSprite == NULL){ // cout << " default addChild " << name << endl; addChild(default_state); } //remove all other states if (press_anim->parentSprite != NULL) removeChild(press_anim); if (rollover_anim->parentSprite != NULL) removeChild(rollover_anim); if (rollout_anim->parentSprite != NULL) removeChild(rollout_anim); //cout<< "ButtonSprite::onRelease::\n"; if (!visible ) return; buttonState = DEFAULT; this->dispatchEvent(ON_RELEASE_OUTSIDE, name); }
void ButtonSprite::onPress(int x, int y, int button) { if (!BaseSprite::visible || !BaseSprite::worldMouseEnabled || !isInRenderTree()) return; if (press_anim->parentSprite == NULL){ // cout << " press addChild " << name << endl; BaseSprite::addChild(press_anim); } //remove all other states if (default_state->parentSprite != NULL) BaseSprite::removeChild(default_state); if (rollover_anim->parentSprite != NULL) BaseSprite::removeChild(rollover_anim); if (rollout_anim->parentSprite != NULL) BaseSprite::removeChild(rollout_anim); // cout<< "ButtonSprite::onPress::\n" << name << endl; buttonState = PRESS; press_anim->gotoAndPlay(1); this->dispatchEvent(ON_PRESS, name); }
void SimpleButton::onReleaseOutside(int x, int y, int button){ cout << "SimpleButton::onReleaseOutside\n"; if (isInRenderTree()) this->dispatchEvent(ON_RELEASE_OUTSIDE, name); }
void SimpleButton::onPress(int x, int y, int button){ cout << "SimpleButton::onPress\n"; if (isInRenderTree()) this->dispatchEvent(ON_PRESS, name); }