Projects > cpp > Issues > Bug #3133

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Box2D and Call to '__invoke' is ambiguous if using CC_CALLBACK_0 macro

Bug #3133 [Closed]
nickflink 2013-11-09 12:35 . Updated about 2 years ago

To reproduce…
sync to cocos2d-x-3.0alpha0

./create-multi-platform-projects.py p HelloWorldk org.cocos2d-x.helloworld -l cpp

cd projects/HelloWorld/
apply patch and then run HelloCpp iOS
diff —git a/Classes/HelloWorldScene.cpp b/Classes/HelloWorldScene.cpp
index 9c6f231..3f35859 100644
— a/Classes/HelloWorldScene.cpp
**+ b/Classes/HelloWorldScene.cpp
@ -1,3 +1,4@
*#include <Box2D/Box2D.h>
#include “HelloWorldScene.h”
USING_NS_CC;
@ -72,9 +73,13@ bool HelloWorld::init
// add the sprite as a child to this layer
this~~>addChild;

  • this~~>runAction)); return true; } *void HelloWorld::aCallback() {
  • log(“HelloWorld::aCallback()”); } void HelloWorld::menuCloseCallback { diff —git a/Classes/HelloWorldScene.h b/Classes/HelloWorldScene.h index 79ce38a..c447287 100644 — a/Classes/HelloWorldScene.h *+ b/Classes/HelloWorldScene.h @ -12,6 +12,7@ public: // Here’s a difference. Method ‘init’ in cocos2d-x returns bool, instead of returning ‘id’ in cocos2d-iphone virtual bool init;
  • void aCallback(); // a selector callback void menuCloseCallback(Object* pSender);
nickflink 2013-11-09 19:06

Here is that patch again only a bit more readable

diff --git a/Classes/HelloWorldScene.cpp b/Classes/HelloWorldScene.cpp
index 9c6f231..3f35859 100644
--- a/Classes/HelloWorldScene.cpp
+++ b/Classes/HelloWorldScene.cpp
@@ -1,3 +1,4 @@
+#include 
 #include "HelloWorldScene.h"

 USING_NS_CC;
@@ -72,9 +73,13 @@ bool HelloWorld::init()
     // add the sprite as a child to this layer
     this->addChild(sprite, 0);

+    this->runAction(CallFunc::create(CC_CALLBACK_0(HelloWorld::aCallback, this)));
     return true;
 }

+void HelloWorld::aCallback() {
+    log("HelloWorld::aCallback()");
+}

 void HelloWorld::menuCloseCallback(Object* pSender)
 {
diff --git a/Classes/HelloWorldScene.h b/Classes/HelloWorldScene.h
index 79ce38a..c447287 100644
--- a/Classes/HelloWorldScene.h
+++ b/Classes/HelloWorldScene.h
@@ -12,6 +12,7 @@ public:
     // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
     virtual bool init();

+    void aCallback();
     // a selector callback
     void menuCloseCallback(Object* pSender);
nickflink 2014-01-27 18:21

This bug went away for me with the update to cocos2d-x-3.0beta.

walzer@cocos2d-x.org 2014-10-08 02:55

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8250

Atom PDF

Status:Closed
Start date:2013-11-09
Priority:Low
Due date:
Assignee:-
% Done:

0%

Category:ios
Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.