DATA_OLD/Cocos2d-x 기능성 게임 개발과정

[D_014] 묶인 스프라이트(Texture) 사용하기

웽웽 2014. 11. 28. 11:24

auto spr = Sprite::create();

spr->setPosition(Vec2(100, 100));

this->addChild(spr);


//통짜 이미지를 텍스쳐로 등록

auto texture = TextureCache::getInstance()->addImage("아틀라스 파일명.png");


auto animation = Animation::create();

animation->setDelayPerUnit(0.2f);


for (int i=0; i<내부의그림개수; i++)

{

animation->addSpriteFrameWithTexture( texture, Rect(56*(i%3), 80*(i%3), 56, 80) );

//텍스쳐 이름, 텍스쳐 배열의 좌표 점화식

}

spr->runAction(RepeatForever::create(Animate::create(animation)));



예제 코드 및 파일