[LayaAirIDE 2.0]Maximum call stack size exceeded

Uncaught RangeError: Maximum call stack size exceeded
    at new EventDispatcher (laya.core.js:1027)
    at new Node (laya.core.js:13292)
    at new Sprite (laya.core.js:13871)
    at new Scene (laya.core.js:23721)
    at new GameMain (bundle.js:6)
    at Function.getCompInstance (laya.core.js:21214)
    at Function.createComp (laya.core.js:21081)
    at Function.createComp (laya.core.js:21111)
    at Function.createByData (laya.core.js:21034)
    at GameMain.createView (laya.core.js:23764)
 
模仿示例代码   才开始就出这错误了   以下附上代码 :
(function () {
    'use strict';
 
    class GameMain extends Laya.Scene {
        constructor(){
            super();
 
            GameMain.instance = this;
 
            Laya.MouseManager.multiTouchEnabled = false;
 
            this.loadScene("main.scene");
 
        }
 
        onEnable() {
            console.log('init');
        }
    }
 
    /**This class is automatically generated by LayaAirIDE, please do not make any modifications. */
 
    class GameConfig {
        static init() {
            //注册Script或者Runtime引用
            let reg = Laya.ClassUtils.regClass;
    reg("script/GameMain.js",GameMain);
        }
    }
    GameConfig.width = 640;
    GameConfig.height = 1136;
    GameConfig.scaleMode ="fixedwidth";
    GameConfig.screenMode = "none";
    GameConfig.alignV = "top";
    GameConfig.alignH = "left";
    GameConfig.startScene = "main.scene";
    GameConfig.sceneRoot = "";
    GameConfig.debug = false;
    GameConfig.stat = false;
    GameConfig.physicsDebug = false;
    GameConfig.exportSceneToJson = true;
 
    GameConfig.init();
 
    class Main {
    constructor() {
    //根据IDE设置初始化引擎
    if (window["Laya3D"]) Laya3D.init(GameConfig.width, GameConfig.height);
    else Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
    Laya["Physics"] && Laya["Physics"].enable();
    Laya["DebugPanel"] && Laya["DebugPanel"].enable();
    Laya.stage.scaleMode = GameConfig.scaleMode;
    Laya.stage.screenMode = GameConfig.screenMode;
    Laya.stage.alignV = GameConfig.alignV;
    Laya.stage.alignH = GameConfig.alignH;
    //兼容微信不支持加载scene后缀场景
    Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
 
    //打开调试面板(通过IDE设置调试模式,或者url地址增加debug=true参数,均可打开调试面板)
    if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true") Laya.enableDebugPanel();
    if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"]) Laya["PhysicsDebugDraw"].enable();
    if (GameConfig.stat) Laya.Stat.show();
    Laya.alertGlobalError(true);
 
    //激活资源版本控制,version.json由IDE发布功能自动生成,如果没有也不影响后续流程
    Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
    }
 
    onVersionLoaded() {
    //激活大小图映射,加载小图的时候,如果发现小图在大图合集里面,则优先加载大图合集,而不是小图
    Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
    }
 
    onConfigLoaded() {
    //加载IDE指定的场景
    GameConfig.startScene && Laya.Scene.open(GameConfig.startScene);
    }
    }
    //激活启动类
    new Main();
 
}());
已邀请:

Laya_z

赞同来自:

你这个报错是堆栈溢出了,看了一下你的demo发现你的runtime脚本关联错了,应该挂载到场景上,不应该挂到子节点上

要回复问题请先

商务合作
商务合作