Cocos2D-JS can#39;t load json file exported from CocosStudio(Cocos2D-JS 无法加载从 CocosStudio 导出的 json 文件)
问题描述
我正在尝试加载从 cocosstudio v2.3.2 导出的 json 文件
I'm trying to load a json file exported from cocosstudio v2.3.2
var myScene = ccs.sceneReader.createNodeWithSceneFile('res/Scene.json');
我从 sample-cocos2d-js-scene-gui-master
得到这段代码
问题是,我收到此错误:找不到解析器:未定义
我该如何解决这个问题?
我对使用 javascript 很陌生,希望有人可以帮助我.谢谢.
I got this code from sample-cocos2d-js-scene-gui-master
The problem is, i get this error: Can't find the parser : undefined
How do i fix this issue?
I'm very new to using javascript and I hope someone can help me with this.
Thank you.
推荐答案
尝试使用 ccs.load("")
新的api.此函数返回表 {node, action}
节点它是你的场景节点"和动作"它是一个时间线动作它是可选的.
您的代码如下所示:
try to use ccs.load("")
It's new api. This function returns table {node, action}
node it's your scene "node" and "action" it's a time line action it's optional.
Your code would look like this:
var sceneRes = ccs.load("res/Scene.json");
this.addChild(sceneRes.node);
如果您想使用该操作,只需为节点运行它即可.
And if you want use the action, just run it for node.
sceneRes.node.runAction(sceneRes.action);
sceneRes.action.gotoFrameAndPlay(0, true);
希望对您有所帮助,对我的英语感到抱歉
Hope this help, and sorry for my english
这篇关于Cocos2D-JS 无法加载从 CocosStudio 导出的 json 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Cocos2D-JS 无法加载从 CocosStudio 导出的 json 文件


基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01