Created
December 31, 2015 17:00
-
-
Save pineoc/ca43124d321acb21486d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool HelloWorld::init() | |
{ | |
/*has some code*/ | |
//CC_CALLBACK_0 function | |
auto sprite1 = Sprite::create("CloseNormal.png"); | |
auto callback = CCCallFunc::create(CC_CALLBACK_0(HelloWorld::myFunction1, this)); | |
sprite1->runAction(callback); | |
this->addChild(sprite1); | |
auto sprite2 = Sprite::create("CloseNormal.png"); | |
auto callback = CCCallFunc::create(CC_CALLBACK_1(HelloWorld::myFunction2, this)); | |
sprite2->runAction(callback); | |
this->addChild(sprite2); | |
auto btn = Button::create("CloseNormal.png","CloseNormal.png"); | |
btn->addTouchEventListener(CC_CALLBACK_2(HelloWorld::myFunction3, this)); | |
this->addChild(btn); | |
} | |
void HelloWorld::myFunction1() | |
{// no passed param | |
CCLOG("myFunction1"); | |
} | |
void HelloWorld::myFunction2(Ref* pSender) | |
{//one passed param | |
CCLOG("myFunction2"); | |
} | |
void HelloWorld::myFunction3(Ref* pSender, Widget::TouchEvent e) | |
{//two passed param | |
//Button event listener | |
CCLOG("myFunction3"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment