cocos2d-x icon indicating copy to clipboard operation
cocos2d-x copied to clipboard

Can't use addTouchEventListener and setLocalZOrder in VideoPlayer

Open michaeeh opened this issue 10 years ago • 1 comments

引擎:cocos2d-x 3.4 环境:iOS, Android VideoPlayer addTouchEventListener 和 setLocalZOrder 无法使用

michaeeh avatar Feb 13 '15 14:02 michaeeh

class TouchableVideoPlayer : public experimental::ui::VideoPlayer {
public:
    virtual bool init() override {
        if (!experimental::ui::VideoPlayer::init()) {
            return false;
        }
        // Enable touch events for the VideoPlayer
        auto touchListener = EventListenerTouchOneByOne::create();
        touchListener->onTouchBegan = CC_CALLBACK_2(TouchableVideoPlayer::onTouchBegan, this);
        Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);

        return true;
    }

    bool onTouchBegan(Touch* touch, Event* event) {
        // Handle touch events here
        // You can forward touch events to the VideoPlayer's parent node or customize the behavior
        return true;
    }
};

ljluestc avatar Sep 17 '23 23:09 ljluestc