SpriteCache사용하기
SpriteCache는 Cocos2d-x가 Sprite액세스 속도를 높이기 위해 제공하는 Sprite의 캐싱 메카니즘입니다.
우리는 Sprite 하나를 생성하여 SpriteFrameCache에 넣을수 있습니다.
C++
// Our .plist file has names for each of the sprites in it. We'll grab
// the sprite named, "mysprite" from the sprite sheet:
auto mysprite = Sprite::createWithSpriteFrameName("mysprite.png");
반대로 SpriteFrameCache에서 Sprite를 가져오는 방법도 있습니다.
먼저 cache에서 SpriteFrame을 얻어오고 그다음에 SpriteFrame을 생성하는것입니다.
C++
// this is equivalent to the previous example,
// but it is created by retrieving the SpriteFrame from the cache.
auto newspriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("Blue_Front1.png");
auto newSprite = Sprite::createWithSpriteFrame(newspriteFrame);
출처: <http://cocos2d-x.org/docs/cocos2d-x/zh/sprites/spriteframe_cache.html>
'Cocos2d-x v3.17 > 기본기능' 카테고리의 다른 글
[Cocos2d-x 기본기능] 이동,회전,스케일 (0) | 2018.08.11 |
---|---|
[Cocos2d-x 기본기능]Action 소개 및 By 와 To 의 구별 (0) | 2018.08.11 |
[Cocos2d-x 기본기능]다각형 스프라이트 Polygon Sprite (0) | 2018.08.11 |
[Cocos2d-x 기본기능]스프라이트 컨트롤하기 (0) | 2018.08.11 |
[Cocos2d-x 기본기능]Sprite 및 SpriteSheet (0) | 2018.08.11 |