Cocos2d-x 3.x游戏开发之旅---(Animation的操作)

来源:互联网 发布:浙江省淘宝司法拍卖网 编辑:程序博客网 时间:2024/06/05 20:42

《Animation》
1、精灵帧缓存,单例类,可用于存储plist文件
SpriteFrameCache* frame_cache = SpriteFrameCache::getInstance();
frame_cache->addSpriteFramesWithFile(“run.plist”);
2、精灵帧
可通过 精灵帧缓存 创建
SpriteFrame* frame = frame_cache->getSpriteFrameByName(
StringUtils::format(“run%d.png”, i));
可用过 create 函数创建
SpriteFrame* frame = SpriteFrame::create(“sprite.png”, Rect(37,0,42,73));

Ps:Sprite 可通过 精灵帧 创建Sprite* sp1 = Sprite::createWithSpriteFrame(    SpriteFrame::create("sprite.png", Rect(37,0,42,73)));

3、Animation对象
需要 SpriteFrame 的Vector数组创建
Vector

阅读全文
0 0