Jump to content

Run a game.state example in in the sandbox, not possible?


Recommended Posts

I'm trying to run one of the Phaser examples in a sandbox to reproduce an audio question by running an altered version of this audio example in the sandbox.

I've altered the code (see link to sandbox below) but when I click the Play tab, the console shows this error message.


Uncaught DOMException: Failed to execute 'postMessage' on 'Window': TypeError: Cannot set property 'prototype' of undefined could not be cloned.

So it seems the sandbox cannot run Phaser games that make use of the StateManager.
Should the sandbox be used in another way for the game.State to work?
Am I doing something wrong here?

See saved sandbox -> https://phaser.io/sandbox/edit/ZBBLlXiA


Link to comment
Share on other sites

Hi @BdR,

That DOMException is resolved with this (mygame.MyGameState was undefined):

mygame.MyGameState = function(game){};

mygame.MyGameState.prototype = {
    preload: function() {

............... more code ...............

Phase Sandbox can use the StateManager. Here a simple example: http://phaser.io/sandbox/UUWjHaIA

Each state must contain at least a one of the required functions: preload, create, update or render (check your "mygame.MyState ")

To change the game size use the size selector in the "Play" tab. Declaring a new Phaser.game adds other canvas, and seems game.destroy() can't be used.


Link to comment
Share on other sites


  • Recently Browsing   0 members

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