Cocos2D-JS 无法加载从 CocosStudio 导出的 json 文件 [英] Cocos2D-JS can't load json file exported from CocosStudio

查看:31
本文介绍了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 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆