我在touchUpInsideAction或touchDragInsideAction中有方法导致按钮按下时ControlButton延迟或缓慢行为
我使用来自扩展的ControlButton与cocos2d-x-3.0alpha1
但是当我尝试从按钮回调中调用方法时
按下按钮行为是堆叠或缓慢的
例如:
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);
现在我尝试从以下方法调用该方法:
void HelloWorld::touchUpInsideAction(Object *sender, Control::EventType controlEvent)
{
//_displayValueLabel->setString(String::createWithFormat("Touch Up Inside.")->getCString());
CCLOGWARN("touchUpInsideAction");
this->pFliteManager->talk("A");
}
或来自
void HelloWorld::touchDownAction(Object *senderz, Control::EventType controlEvent)
{
//_displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString());
CCLOGWARN("touchDownAction");
this->pFliteManager->talk("A");
}
该功能正在执行,但该按钮不会执行点击效果 为什么呢?