quick cocos creator plist怎么调用plist文件

cocos2d-x 3.2 lua 怎样加载plist文件_百度知道
cocos2d-x 3.2 lua 怎样加载plist文件
我有更好的答案
plist&)localanimation=cache:getAnimation(&quotlocalcache=cc.AnimationCache:setDelayPerUnit(0.25)animation:setRestoreOriginalFrame(true)localaniamte=cc:getInstance()cache:addAnimations(&animations-2;dance_1&)animation
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Cocos2d3.0
制作PList文件
auto root = Dictionary::create();
auto string = String::create("string element value");
root->setObject(string, "string element key");
auto array = Array::create();
auto dictInArray = Dictionary::create();
dictInArray->setObject(String::create("string in dictInArray value 0"), "string in dictInArray key 0");
dictInArray->setObject(String::create("string in dictInArray value 1"), "string in dictInArray key 1");
array->addObject(dictInArray);
array->addObject(String::create("string in array"));
auto arrayInArray = Array::create();
arrayInArray->addObject(String::create("string 0 in arrayInArray"));
arrayInArray->addObject(String::create("string 1 in arrayInArray"));
array->addObject(arrayInArray);
root->setObject(array, "array");
auto dictInDict = Dictionary::create();
dictInDict->setObject(String::create("string in dictInDict value"), "string in dictInDict key");
//add boolean to the plist
auto booleanObject = Bool::create(true);
dictInDict->setObject(booleanObject, "bool");
//add interger to the plist
auto intObject = Integer::create(1024);
dictInDict->setObject(intObject, "integer");
//add float to the plist
auto floatObject = Float::create(f);
dictInDict->setObject(floatObject, "float");
//add double to the plist
auto doubleObject = Double::create();
dictInDict->setObject(doubleObject, "double");
root->setObject(dictInDict, "dictInDict, Hello World");
// end with /
std::string writablePath = FileUtils::getInstance()->getWritablePath();
std::string fullPath = writablePath + "text.plist";
if(root->writeToFile(fullPath.c_str()))
log("see the plist file at %s", fullPath.c_str());
log("write plist file failed");
auto loadDict = __Dictionary::createWithContentsOfFile(fullPath.c_str());
auto loadDictInDict = (__Dictionary*)loadDict->objectForKey("dictInDict, Hello World");
auto boolValue = (__String*)loadDictInDict->objectForKey("bool");
CCLOG("%s",boolValue->getCString());
auto floatValue = (__String*)loadDictInDict->objectForKey("float");
CCLOG("%s",floatValue->getCString());
auto intValue = (__String*)loadDictInDict->objectForKey("integer");
CCLOG("%s",intValue->getCString());
auto doubleValue = (__String*)loadDictInDict->objectForKey("double");
CCLOG("%s",doubleValue->getCString());他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)quick cocos 怎么调用plist文件_百度知道
quick cocos 怎么调用plist文件
我有更好的答案
要导入的话你指的plist是用TexturePacker合成的大图吗? 如果是的话,只要把大图跟plist文件都放在Resource文件夹下。 然后在cocos2d-x的项目代码中可以这样操作: CCSpriteFrameCache *pFrameCache = CCSpriteFrameCache::sharedSpriteFrameC.
采纳率:91%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。08:41:00 UTC
我用多张图片生成了一张图片还有个.plist文件,quick cocos该怎么通过这个.plist文件获取图片的
01:40:33 UTC
你可以用addSpriteFramesWithFile加载.plist文件和这个大图。之后如果创建精灵什么的直接用那个小图名字就可以了。如果不记得小兔名字了,也可以打开.plist查看。
02:19:11 UTC
这里我用addSpriteFramesWithFile 报错的
能给看一下这是什么错么
local frameCache
= cc.SpriteFrameCache:getInstance(); frameCache:addSpriteFramesWithFileContent("img/card.plist","img/card.png")
第二句话报错
invalid arguments in function 'lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent'
02:39:07 UTC
用display.addSpriteFramesWithFile试试
02:53:30 UTC
这个也不好使
直接报空了
display.addSpriteFramesWithFile("img/card.plist","img/card.png")
报错attempt to call field 'addSpriteFramesWithFile' (a nil value)
03:04:37 UTC
扔个Demo给我吧,我看下。
05:47:26 UTC
cocos IDE新建个demo压缩后还有100M 传了两次传半天都没成功
我就是新建个Demo在
res下考入 .plist 跟 .png俩文件然后在MainScene:ctor() 里调用
display.addSpriteFramesWithFile("card.plist","card.png")
local frameCache
= cc.SpriteFrameCache:getInstance()
frameCache:addSpriteFramesWithFileContent("card.plist","card.png")
01:10:46 UTC
就这么要沉了么
08:15:41 UTC
同样的问题
请问你解决了没?

我要回帖

更多关于 cocos plist文件 的文章

 

随机推荐