ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • cocos2d-x animation 정리
    Pause @/Cocos2d-x2 2013. 6. 30. 14:23

    CCAnimation

    1. Animation Process

    CCSprite -> CCAnimation -> CCAnimate -> runAction;


    dance_man.zip


    2. File : addSpriteFrameWithFileName

    CCAnimation *animation = CCAnimation::create();

    animation->setDelayPerUnit(0.3f);

    animation->addSpriteFrameWithFileName("grossini_dance_01.png");

    animation-> addSpriteFrameWithFileName("grossini_dance_02.png");

    animation-> addSpriteFrameWithFileName("grossini_dance_03.png");


    CCAnimate *animate = CCAnimate::create(animation);


    spr->runAction(CCRepeatForever::create(animate));


    3. Texture : addSpriteFrameWithTexture

    CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("grossini_dance_atlas.png");

    for(int i=0;i<14;i++) {

    animation->addSpriteFrameWithTexture(texture, CCRect((i%5)*85, (i/5)*121, 85, 121));

    }


    4. CCSpriteFrame : addSpriteFrame

    CCSpriteFrameCache::sharedSpriteFrameCache()->

    addSpriteFramesWithFile("grossini_gray.plist");


    char buf[256];

    for(int i=1; i<15;i++) {

    sprintf(buf, "grossini_dance_gray_%02d.png", i);

    CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(buf);

    animation->addSpriteFrame(frame);

    }




    HelloWorldScene.cpp


    'Pause @ > Cocos2d-x2' 카테고리의 다른 글

    cocos2d-x transition, parallaxnode  (0) 2013.06.30
    cocos2d-x 스케쥴update, CCSpriteBatchNode  (0) 2013.06.30
    cocos2d-x 터치 및 스케쥴 정리  (0) 2013.06.29
    cocos2d-x 정리 2일차  (0) 2013.06.24
    cocos2d-x 정리..  (0) 2013.06.23
Designed by Tistory.