cocos 2 dxアニメーションを作成するいくつかの方法

2006 ワード

——————— 1. 大図を使用したフレームアニメーションの作成
    //           

SpriteFrameCache::getInstance()->addSpriteFramesWithFile(大図名.plist);
//アニメーションの配列Vector{SpriteFrame*> sf 2;(カッコのペア)を保存
//動作を実行するノードcocos 2 d::Sprite*m_sprite = Sprite::create(); addChild(m_sprite);
//                       
sf2.pushBack(SpriteFrameCache::getInstance()->getSpriteFrameByName("eff_slide0.png"));
sf2.pushBack(SpriteFrameCache::getInstance()->getSpriteFrameByName("eff_slide1.png"));

//     
m_slideAnimation = RepeatForever::create(Animate::create(Animation::createWithSpriteFrames(sf2, 0.1f)));

//     retain ,          
m_slideAnimation->retain();

//        
m_sprite->runAction(m_slideAnimation);

—————– 2. cococostudioでエクスポートしたアニメーションcococos 2 d::Node*m_node;//ノードcocostudio::timeline::ActionTimeline*m_action;//ノード上のアクション//エクスポートされたファイルからノードとアクションを作成し、ファイルのパスとファイル名は必ず同じm_node = CSLoader::createNode(“Effect/Effect_baopo.csb”); m_action = CSLoader::createTimeline(“Effect/Effect_baopo.csb”); //ノードrunを動作させ、ノードツリーにノードをバインドm_node->runAction(m_action); addChild(m_node);
        //          play        。          ,          
    m_action->play("baopo", true);

——————3. spineでエクスポートしたアニメーション
    //          
    #include {spine/spine-cocos2dx.h> (     )
    #include "spine/spine.h"

        // spine      
    spine::SkeletonAnimation* m_heroAnimation;
    m_heroAnimation= SkeletonAnimation::createWithFile("   .json", "   .atlas");
        // spine      cocos contentSize 0,              。             ,       ,         
    m_heroAnimation->setContentSize(Size(tHeroSize.width, tHeroSize.height));
    m_heroAnimation->setAnchorPoint(Point(0.5, 0));
    addChild(m_heroAnimation);

    //        setAnimation        (                       ,         ,            )
m_heroAnimation->setAnimation(0, animationName, loop);