Jump to content

Maximum call stack size exceeded on Stage.update easeljs


Recommended Posts

I'm trying to create a little game using easelJs library. I started to write the function for create the map, and this is my little code:

<!DOCTYPE html>    <html>        <head>            <title>My Game</title>            <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>            <script src="http://code.createjs.com/easeljs-0.7.0.min.js" type="text/javascript"></script>            <script>                var canvas;                var map;                function Map(canvas, obstacleImage){                    var spriteSheet = new createjs.SpriteSheet({                        images: [obstacleImage]                    });                    var obstacles = [];                    this.width = canvas.width;                    this.height = canvas.height;                    this.stage = new createjs.Stage(canvas);                    for(var i = 0; i < map1.length; i++){                        for(var j = 0; j < map1[i].length; j++){                            if(map1[i][j] == 1){                                var obstacle = new createjs.BitmapAnimation(spriteSheet);                                obstacle.x = j * spriteW;                                obstacle.y = i * spriteH;                                this.stage.addChild(obstacle);                                obstacles.push(obstacle);                            }                        }                    }                }                function gameStart(){                    canvas = document.querySelectorAll("canvas")[0];                    map = new Map(canvas, "Sprites/rock.png");                    createjs.Ticker.addEventListener("tick", drawHandler);                }                function drawHandler(){                    map.stage.update();                }            </script>        </head>        <body onload="gameStart()">            <canvas height="624px" width="1024px" id="game_canvas">            </canvas>        </body>    </html>

So i execute my html code on my browser and the result is "Uncaught RangeError: Maximum call stack size exceeded" when the Stage.update() function is called. Could the problem be i add too many children to the Stage? If so, how can i add all the obstacles to my map without receive any error??

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...