GameCorder.net

このエントリーをはてなブックマークに追加

CallBack Function to FadeOut Action in cocos2dx

How to CallBack Function when fadeout animation action done.
In cocos2dx use CC_CALL_BACK fuction to use callback.

In this Example use callback when fade out is done.
To fade out use FadeOut class.
Let's see the example.

// button
cocos2d::ui::Button* button
// 1.fade out animation
auto action = FadeOut::create(1);
// 2.call ToucNumberScene class fuction
auto fadeOutCallBack = CallFuncN::create(CC_CALLBACK_1(TouchNumberScene::setNewNumberButton, this,button));
// 3.use Sequence class
auto seq = Sequence::create(action, fadeOutCallBack, nullptr);
// 4.finaly run fadeout action
button->runAction(seq);
		

Let's see setNewNumberButton function in TouchNumberClass.

void TouchNumberScene::setNewNumberButton(Node* pSender,ui::Button* button){
	// ...
}
		

in the function needs arg Node*
and I want to use Ui Button.
so set arg 2 ui::Button*
Ofcouse We can use this button to cast Node* pSender.
In this case I put arg2 to button.