cocos2d-x中读取plist文件和集成的png图片
//精灵帧缓存读取plist SpriteFrameCache *sfc = SpriteFrameCache::sharedSpriteFrameCache(); sfc->addSpriteFramesWithFile("pic/sprites.plist"); //加载大图 auto sprites = SpriteBatchNode::create("pic/sprites.png"); sprites->setPosition(Point::ZERO); this->addChild(sprites,1); //从大图中截取小图创建精灵 auto s = Sprite::createWithSpriteFrameName("grossini_dance_01.png"); s->setPosition(Point(CCRANDOM_0_1() * 480, CCRANDOM_0_1() * 320)); this->addChild(s);
工作中的代码:
self.cache = cc.SpriteFrameCache:getInstance() self.cache:addSpriteFrames("game_element.plist") cc.SpriteFrameCache:getInstance():addSpriteFrames("public/im_head.plist") local fishName=string.format("Avatar%d.png", GlobalUserItem.wFaceID) local sprite = cc.Sprite:createWithSpriteFrameName(fishName) sprite:setPosition(48.5,706.4) sprite:addTo(self) sprite:setScale(0.55) cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("public/im_head.plist")
posted on 2018-04-04 10:48 echo111333 阅读(547) 评论(0) 编辑 收藏 举报