Skip to content

Instantly share code, notes, and snippets.

@pineoc
Created December 31, 2015 17:00
Show Gist options
  • Save pineoc/ca43124d321acb21486d to your computer and use it in GitHub Desktop.
Save pineoc/ca43124d321acb21486d to your computer and use it in GitHub Desktop.
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