Hey , im using the ControlButton from the Extensions with cocos2d-x-3.0alpha1
but when i try to call method from the button callbacks
the button press Behavior is stack or sluggish
for example :
auto backgroundButton = Scale9Sprite::create("extensions/button.png");
auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png");
auto titleButton = LabelTTF::create("Touch Me!", "Marker Felt", 30);
titleButton->setColor(Color3B(159, 168, 176));
ControlButton *controlButton = ControlButton::create(titleButton, backgroundButton);
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED);
controlButton->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED);
controlButton->setAnchorPoint(Point(0.5f, 1));
controlButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(controlButton, 1);
// Sets up event handlers
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), Control::EventType::TOUCH_DOWN);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragInsideAction), Control::EventType::DRAG_INSIDE);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragOutsideAction), Control::EventType::DRAG_OUTSIDE);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragEnterAction), Control::EventType::DRAG_ENTER);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragExitAction), Control::EventType::DRAG_EXIT);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE);
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchCancelAction), Control::EventType::TOUCH_CANCEL);
// test for issue 2882
controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchBitmaskAction),
Control::EventType::TOUCH_DOWN | Control::EventType::DRAG_INSIDE | Control::EventType::DRAG_OUTSIDE | Control::EventType::DRAG_ENTER | Control::EventType::DRAG_EXIT | Control::EventType::TOUCH_UP_INSIDE | Control::EventType::TOUCH_UP_OUTSIDE | Control::EventType::TOUCH_CANCEL | Control::EventType::VALUE_CHANGED);
now i try to call the method from :
void HelloWorld::touchUpInsideAction(Object *sender, Control::EventType controlEvent)
{
//_displayValueLabel->setString(String::createWithFormat("Touch Up Inside.")->getCString());
CCLOGWARN("touchUpInsideAction");
this->pFliteManager->talk("A");
}
or from
void HelloWorld::touchDownAction(Object *senderz, Control::EventType controlEvent)
{
//_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
CCLOGWARN("touchDownAction");
this->pFliteManager->talk("A");
}
the function is executing great but the button doesn’t do the click down effect
why?