{"id":414,"date":"2012-08-02T15:32:27","date_gmt":"2012-08-02T15:32:27","guid":{"rendered":"http:\/\/www.blogs.abeazam.com\/dev\/?p=414"},"modified":"2012-11-13T11:16:26","modified_gmt":"2012-11-13T11:16:26","slug":"implementing-cccallfunc-cocos2d-x-2-0","status":"publish","type":"post","link":"http:\/\/www.blogs.abeazam.com\/dev\/2012\/08\/implementing-cccallfunc-cocos2d-x-2-0\/","title":{"rendered":"Implementing CCCallFunc Cocos2d-X 2.0"},"content":{"rendered":"<p>This is a simple way of implementing CCCallFunc.<\/p>\n<p>ClassA wants to pass a function reference to ClassB.<\/p>\n<p>CCCallFunc calls a function without any parameters. If you want to get the CCObject that called it then use CCCallFuncN and if you want to pass your own data use CCCallFuncND<\/p>\n<p>In ClassB header create a variable to hold the callFunction.<\/p>\n<p>[cpp]<br \/>\n\/\/ClassB.h<br \/>\npublic:<br \/>\nCCCallFunc callFuncHolder;<br \/>\n[\/cpp]<\/p>\n<p>In ClassB implementation call the passed in function.<br \/>\n[cpp]<br \/>\n\/\/ClassB.cpp<\/p>\n<p>void someMethod()<br \/>\n{<br \/>\n\/\/this calls the passed in method if there is no set method it will not error<br \/>\ncallFuncHolder.execute();<br \/>\n}<\/p>\n<p>[\/cpp]<\/p>\n<p>In class ClassA implementation.<\/p>\n<p>[cpp]<br \/>\n\/\/ClassA.cpp<br \/>\nvoid init()<br \/>\n{<br \/>\nClassB *cb = new ClassB();<br \/>\ncb->callFuncHolder = *CCCallFunc::create(this, callfunc_selector(methodPassed));<\/p>\n<p>\/\/when ClassB is ready it calls methodPassed<br \/>\n}<\/p>\n<p>\/\/this is the method passed into the CCCallFunc<br \/>\nvoid methodPassed()<br \/>\n{<br \/>\nCCLog(&#8220;methodPassed call form else where&#8221;);<br \/>\n}<br \/>\n[\/cpp]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a simple way of implementing CCCallFunc. ClassA wants to pass a function reference to ClassB. CCCallFunc calls a function without any parameters. If you want to get the CCObject that called it then use CCCallFuncN and if you want to pass your own data use CCCallFuncND In ClassB header create a variable to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,82,83,84,18,25,26],"tags":[85],"_links":{"self":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/414"}],"collection":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/comments?post=414"}],"version-history":[{"count":7,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":427,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/posts\/414\/revisions\/427"}],"wp:attachment":[{"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/media?parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/categories?post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.blogs.abeazam.com\/dev\/wp-json\/wp\/v2\/tags?post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}