EventDispatcher has no function

EventDispatcher has no function
0

When I use the EventDispatcher in a few new cpp files, it says that class EventDispatcher doesn’t have function addEventListenerWithSceneGraphPriority. I tried to use other functions too but none works. The ide, however, can trace every function contained in the class. Here is some images

You add events to the Director.

https://docs.cocos2d-x.org/cocos2d-x/v3/en/event_dispatcher/

You mean using the below functions to add event to the Director?

Director::getInstance()->getEventDispatcher->addEvent…
or
_eventDispatcher->addEvent…

If this is what you mean then I have tried both of them and it still say Class EventDispatcher doesn’t have a function ‘addEvent…’ when I switch to a new file within a project.

Look at the link I posted. It answers everything you asked. Also look at cpp-tests.

Hello slackmoehrle,

The error disappear when I include the BaseTest in the NewEventDispatcherTest.

I am sorry if I am stupid but I don’t know the explanation to the solution. Would you be kind enough to help me understand it?

Of course I followed the link and look at the cpp-test but the problem wasn’t resolved until I include the base test.

Thank you in advance

Found it. I have to include the CCEventDispatcher. Looks like I’m just stupid afterall.

Thx very much 4 the feedback. Hope you have a good day :slight_smile:

Why cant you include cocos2d.h? Shouldn’t need to include CCEventDispatcher

And there is ZERO reason to include any of the tests in your game. DO NOT DO THIS>

How did you create your game?

Did you run cocos new ......?

If you have to include more headers then something is wrong.

Yeah well, to simply put it. I included the test just to see why it works and then narrow it down to the specific component that make the game works and yes I ran cocos new.

I learned new things by making mistakes and not really the type to read the instructions first before doing something thus the questions might be a bit stupid to ask.

Thank you again for spending the time answering my questions. I will make sure to thoroughly read the docs this time :slight_smile:

Hope you have a nice day

we all need to learn. Ask anything you need.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.