//4个精灵在中?位置先后移动到屏幕的4个?
void SecondaryJump:: FourSprites (cocos2d :: Ref * ref )
{
auto act = Sequence :: create( MoveTo ::create (1, Point(10, 10)), CallFuncN ::create ([=]( Node * node ){
sp5 ->runAction ( Sequence:: create (MoveTo :: create(1, Point (10, 630)), CallFuncN :: create([=]( Node * node ){
sp6 ->runAction ( Sequence:: create (MoveTo :: create(1, Point (950, 630)), CallFuncN :: create([=]( Node * node ){
sp7 ->runAction ( Sequence:: create (MoveTo :: create(1, Point (950, 10)), nullptr ));
}), nullptr ));
}), nullptr ));
}), nullptr );
sp4-> runAction (act );
} //动画回调
auto callFunc = CallFuncN :: create([=]( Node * node )
{
node ->setVisible ( false);
});
auto act = Sequence :: create( Spawn ::create ( RotateTo:: create (2, 720), MoveBy :: create(2, Point (100, 0)), nullptr ), MoveBy ::create (1, Point(100, 0)), JumpBy ::create (0.2f, Point(0, 0), 100, 1), callFunc , CallFuncN ::create ([=]( Node * node ){ CocosDenshion :: SimpleAudioEngine:: sharedEngine ()->playBackgroundMusic ( "music/game_music.wav", true ); }),
nullptr );
sp2-> runAction (act );void SecondaryJump:: Jump (cocos2d :: Ref * ref )
{
MenuItemFont * item = (MenuItemFont *) ref;
auto repeatAct = Repeat :: create( Sequence ::create ( MoveBy:: create (0.01f, Point (3, 3)), MoveBy ::create (0.01f, Point(-3, -3)), MoveBy ::create (0.01f, Point(3, -3)), MoveBy ::create (0.01f, Point(-3, 3)), nullptr ), 6);
item-> runAction (repeatAct );
}void FrameAnimation:: Morning_0623 (cocos2d :: Ref * ref )
{
auto animation = Animation :: create();
for ( int i = 2; i <= 6; i ++)
{
String fileName = StringUtils:: format ("coc/characters_lowres/%d.0.png" , i);
animation ->addSpriteFrameWithFileName ( fileName. getCString ());
}
animation-> setDelayPerUnit (0.05f);
animation-> setLoops (-1);
auto animate = Animate :: create( animation );
auto pArr = PointArray :: create(5);
pArr-> addControlPoint (Point (100, 0));
pArr-> addControlPoint (Point (100, 200));
pArr-> addControlPoint (Point (300,200));
pArr-> addControlPoint (Point (300, 400));
auto move = CardinalSplineBy :: create(5, pArr , 1);
auto act = Spawn :: create( animate , move , nullptr);
ccBezierConfig bezierCon ;
bezierCon. controlPoint_1 =CCPointMake (200, 150); //控制点1
bezierCon. controlPoint_2 =CCPointMake (200, 160); //控制点2
bezierCon. endPosition =CCPointMake (540, 100); // 结束位置
sp-> runAction (Spawn :: create( act , BezierBy :: create(3, bezierCon ), nullptr ));
}cocos2dx 3.1从零学习(五)——动画,布布扣,bubuko.com
原文:http://blog.csdn.net/hanbingfengying/article/details/34424133