@SpecialDevAnd wrote:
Hello!
I have a class TouchableSprite
class TouchableSprite : public Sprite { public: virtual bool init(); CREATE_FUNC(TouchableSprite); }; bool TouchableSprite::init() { if (!Sprite::init()) { return false; } this->setTexture("t1.png"); this->setPosition(100.0, 100.0); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [=](Touch* touch, Event* event) { auto location = touch->getLocation(); auto rect = this->getBoundingBox(); if (rect.containsPoint(location)) this->setTexture("t2.png"); return true; }; _eventDispatcher->addEventListenerWithFixedPriority(listener, 1); #endif // () #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) auto listener = EventListenerMouse::create(); listener->onMouseDown = [=](Event* event) { auto eventMouse = (EventMouse*)event; auto location = eventMouse->getLocation(); auto rect = this->getBoundingBox(); if (rect.containsPoint(location)) this->setTexture("t2.png"); return true; }; _eventDispatcher->addEventListenerWithFixedPriority(listener, 1); #endif // () return true; }
that I add to HelloWorld scene
// add the sprite as a child to this auto ts = TouchableSprite::create(); this->addChild(ts);
I suppose that this code should work identically on android and on win32, but it is not. On android all works well, but on win32 nothing happens.
Please help me understand what I'm doing wrong.
I use cocos 3.10
windows 10
and visual studio 2015
Posts: 3
Participants: 2