I don’t know from where I am getting this error.
I will upload source code.
I am totally confused in this and don’t know where should I make the changes.
BaseScene.cpp (53.3 KB)
Base.zip (1.2 KB)
BaseScene.h is not downloadable.
Scene* BaseScene::scene()
{
// ‘scene’ is an autorelease object
Scene scene = Scene::create();
// add layer as a child to scene
Layer layer = new BaseScene();
scene->addChild(layer);
layer->release();
return scene;
}
what changes do I need to make it in this function?
I have uploaded the header file in zip folder and not it can be downloaded.
Which version of cocos2d-x you are using?
Version: 3.10
void pauseCliked(); should be void pauseCliked(Ref* sender);
Thanks a lot.
It worked.
But its not giving the output as it has to.
Position is not correct and even touch is not working.
Can you go through my code once?
These functions won’t work:
void onTouchesBegan(Set *pTouches, Event *pEvent);
void onTouchesMoved(Set *pTouches, Event *pEvent);
void onTouchesEnded(Set *pTouches, Event *pEvent);
You have to replace them with:
virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event);
virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event);
virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event);
Do I have to also make EventListener for them?
No.
But you have to call setTouchMode(Touch::DispatchMode::ALL_AT_ONCE) so that these touch callbacks can be invoked properly, or if you want to handle only single touch, just override:
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
virtual void onTouchMoved(Touch *touch, Event *unused_event);
virtual void onTouchEnded(Touch *touch, Event *unused_event);
Where do I need to call setTouchMode(Touch::DispatchMode::ALL_AT_ONCE) and how to implement this function?
I have never used this function before.
this->setTouchEnabled(true);
this->setTouchMode(Touch::DispatchMode::ALL_AT_ONCE)
I Implemented this but its the same. No change at all.
Touches doesn’t work.
If you need then I can Upload complete source code again.
Touches are working when I use “this->setTouchMode(Touch::DispatchMode::ONE_BY_ONE)”
But it works only once. After the touch ended once its not working again.
I used the log and checked that all the three methods “onTouchBegan, onTouchMoved and onTouchEnded are working”
What should I do now?
I don’t understand that onTouchBegan, onTouchMoved, onTouchEnded work but the touch does not work.
If onTouchBegan is called, the touch should work.
I mean touches work only once when the application starts.
onTouchBegan runs every time but onTouchEnded works only once.
I am totally confused what to do next.
BubbleShooter.zip (26.8 KB)
I have uploaded all my source code.
Any help will be highly appreciated.
Thanks
You should return true; in onTouchBegan.
It seems that you are migrating from cocos2d-x v2 and you commented out some lines which makes the game does not work properly.
ballFired is never reset to false, which makes onTouchEnded returns immediately.