Hey
im using ui::Slider for in game GUI for real time testing , now i have many element in the game that are
touchble , the Slider is on simple Sprite that acted as the container for the slider .
and the Sprite container on the game Sprite .
so its like this :
GameSprite
|
-- > SliderContainer
|
--> ui::Slider
the problem is when i try to use the slider the touch is somehow pass throw the slider and the objects beneath the Slider container are capturing the touch
in my gameSprite the touch Priority looks like this
void HelloWorld::onEnter()
{
Layer::onEnter();
_eventDispatcher->addEventListenerWithFixedPriority(_listener, 1);
auto listener_Touches = EventListenerTouchAllAtOnce::create();
listener_Touches->onTouchesMoved = CC_CALLBACK_2(HelloWorld::onTouchesMoved, this);
listener_Touches->onTouchesBegan = CC_CALLBACK_2(HelloWorld::onTouchesBegan, this);
listener_Touches->onTouchesEnded = CC_CALLBACK_2(HelloWorld::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener_Touches, this);
}
and the slider definition looks like this:
ui::Slider* slider = ui::Slider::create();
slider->setTag(t);
slider->loadBarTexture("cocosui/sliderTrack.png", ui::Widget::TextureResType::LOCAL); // what the slider looks like
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "", ui::Widget::TextureResType::LOCAL);
slider->loadProgressBarTexture("cocosui/sliderProgress.png", ui::Widget::TextureResType::LOCAL );
slider->setPercent(CurrentPercent);
slider->addEventListener([ slider , _pClsDataMember](Ref* sender, ui::Slider::EventType type)
{
switch (type)
{
case ui::Slider::EventType::ON_PERCENTAGE_CHANGED:
{
break;
}
default:
{
break;
}
}
});
slider->setRotation(-90);
slider->setAnchorPoint(Vec2::ZERO);
slider->setPosition(Vec2(x,y));
_container->addChild(slider,100);
return slider;
}
in shout how to make the slider as top Priority for touch or the Spirit that contain the slider