I use cocos2d-x 3.0 RC1, and I have the following question. As I knew, cocos2d-x had a single (centralized) event dispatcher, and it was implemented as a singleton so that I could send event from everywhere to anywhere. Now in the final version it is not a singleton and I cannot use EventDispatcher::getInstance()
. Why the centralized EventDispatcher was considered wrong? In this case how I can send an event from a class that is not a cocos2d::Node
to another class that is not a cocos2d::Node
either?
Asked
Active
Viewed 1,291 times
3
-
@LearnCocos2D I have noticed that you always delete `cocos2d` tag. Is it some kind of a mission? :) – Narek Apr 23 '14 at 09:43
-
I delete the cocos2d-iphone tag where it doesn't fit. People often add [cocos2d] (despite the tag description stating NOT TO USE THIS TAG) because it's synonymous with and gets expanded to [cocos2d-iphone] which is a different engine than [cocos2d-x]. Only high-level concepts are shared between the cocos2d engines but each needs to be viewed as separate frameworks really. So I remove these conflicting tags (usually cocos2d-iphone) so that users won't happen to answer with a solution that won't work with the engine actually being used (ie an ObjC answer for cocos2d-x won't be very helpful). – CodeSmile Apr 23 '14 at 11:16
-
But it should be helpful, these are ports and have the same API, haven't they? – Narek Apr 23 '14 at 18:22
-
Not really. The method/class names may be related if not identical, but that's hardly helpful except for maybe some rudimentary issues. The above question for example has no real relation to cocos2d-iphone. In v3 there's no EventDispatcher, in v2 and earlier there's CCEventDispatcher and its job is to forward OS X events to delegates, not sending notifications to other classes. Plus getInstance is not part of the cocos2d-iphone API anywhere, instead singleton accessors usually use the "sharedSomething" naming scheme in cocos2d-iphone. The cocos2d-iphone tag is often more confusing than helpful – CodeSmile Apr 23 '14 at 21:29