Skip to content

Instantly share code, notes, and snippets.

@Sumolari
Last active April 18, 2016 16:38
Show Gist options
  • Save Sumolari/f0b80d1dfb83029e615397e3f046b291 to your computer and use it in GitHub Desktop.
Save Sumolari/f0b80d1dfb83029e615397e3f046b291 to your computer and use it in GitHub Desktop.
Custom FiniteTimeActions demo with MawKit
#include "MawKit/FiniteTimeActions.hpp"
void runPickupCoinAnimation( cocos2d::Node *coin, cocos2d::Node *chest ) {
// Move coin to chest.
auto moveCoinToChest = MK::Actions::MoveToNode::create( 0.25, chest );
// Bounces chest.
std::function<void( void )> bounceChest = [=]() { chest->bounce(); };
// Move coin to chest, then bounce chest, then remove coin form parent.
coin->runAction( cocos2d::Sequence::create(
moveCoinToChest,
cocos2d::CallFunc::create( bounceChest ),
MK::Actions::RemoveFromParent::create( 0.1 ),
nullptr
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment