求教:某类 is not defined

我正在做从场景SceneMenu切入另一个场景SceneChooseLevel,json场景是切过去了,但是绑定的类无法初始化,报错如下

JS Default_Error_Reporter   

另外,我在main.js的loadJS里已经加入了对这个新的JS文件的Require了:

loadJS: function(){
                       Require("SceneMenu.js");
                       Require("SceneChooseLevel.js");
                   },

然后这是SceneMenu里按键响应切场景的代码:

onClickStart:function(){
                      print("onClickStart");
                      var self = this;
                      game.js_Scene = game.js_Game.createSceneWithJson("SceneChooseLevel.json");
                      game.js_Scene.onEnter = function (){
                        print("scene onenter!");
                        var sceneChooseLevel = new SceneChooseLevel(10000, "ui_choose_level");
                      }
                      game.js_Scene.onExit  = function (){
                        //self.sceneOnExit();
                      }
                      game.js_Game.runWithScene(game.js_Scene);
                  }

请发一下 SceneChooseLevel.js 里面的代码

— Begin quote from ____

chengstory 发表于 2012-10-31 17:53 url

请发一下 SceneChooseLevel.js 里面的代码

— End quote

SceneChooseLevel.js:

var SceneChooseLevel = Class(object, {
                  onCreate:function(objectTag)
                  {
                       
                      //ui
                      var ui = GetSubComponent(objectTag, "ui_choose_level");
                       print("SceneChooseLevel   " + ui);
                      var backButton = ui.getNodeByName("btBack");
                      backButton.onClick = function(){
                           game.js_Game.exit();
                      }
                  }
                  
                  });

— Begin quote from ____

zephyr1125 发表于 2012-11-1 10:37 url

SceneChooseLevel.js:

— End quote

检查下 js文件有没有添加到资源里,

js默认不会添加到这里,需要手动添加;

— Begin quote from ____

jxhgzs 发表于 2012-11-2 09:55 url

检查下 js文件有没有添加到资源里, js默认不会添加到这里,需要手动添加;

— End quote

资源里不添加的话就xcode里无法找到你写的js文件;在widows下只要放到Resource中就可以,android直接放到资源路径下面就可以,只有xcode需要这一步

— Begin quote from ____

jxhgzs 发表于 2012-11-2 09:58 url

资源里不添加的话就xcode里无法找到你写的js文件;在widows下只要放到Resource中就可以,android直接放到 …

— End quote

看不到图,但如果指的是要把资源拖入这里的话,我肯定是做了的,如下图:
25
并且我的Android项目也有这个问题,切不到别的场景里。

— Begin quote from ____

zephyr1125 发表于 2012-11-2 10:46 url

看不到图,但如果指的是要把资源拖入这里的话,我肯定是做了的,如下图:

并且我的Android项目也有这个 …

— End quote

同样的问题,就正解!

GNU gdb 6.3.50-20050815 (Apple version gdb-1823) (Thu Oct 18 21:41:37 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “x86_64-apple-darwin”.Attaching to process 2250.
2012-11-05 14:35:57.627 Samples Application windows are expected to have a root view controller at the end of application launch
Cocos2d: Game.loadJS()
Assertion failure: !cx->isExceptionPending(), at …/jscntxtinlines.h:317
sharedlibrary apply-load-rules all
Current language: auto; currently c++

好好的一个demo,编译几次就Crash哦。:@

mark…