Jump to content

How


oliversb
 Share

Recommended Posts

TypeError: texture is undefined phaser.js:1717

"Phaser.StateManager - No state found with the key: pmSCENEScene" phaser.js:14293

TypeError: _this.boot is not a function

 

How can I use this information to fix bugs in my Javascript code? Is there a particular system I should be using for debugging. I am trying to add a sprite to my game and it says 'texture is undefined'. I added a state as shown in the example and then started it and I've followed the code here https://github.com/photonstorm/phaser/wiki/Phaser-General-Documentation-:-States. I don't know where the _this.boot comes from. So please help.

 

Thanks

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>as</title>

<script src="src/prototype.js" type="text/javascript"></script>
<script src="src/phaser.js" type="text/javascript"></script>
<script src="src/PowerModeEngine.js" type="text/javascript"></script>
<style type="text/css">
body {
background-color: #3B3B3B;
font-family: arial, verdana, sans-serif;
font-size: 12px;
}

#canvas{
background-color: #FFFFFF;
display: block;
margin: 0 auto;
}

</style>

<script type="text/javascript">

//End Of Variables

function init() {
game = Phaser.Game(640, 480, Phaser.AUTO, 'game');
game.state.add('pmSCENEScene', game.pmSCENEScene);
game.state.start('pmSCENEScene');
}

function pmOBJECTObject(x, y, sprite) {

//pmOBJECTObject

PowerModeObject.call(this, game, x ,y);
function theConstructor () {
//pmOBJECTObjectConstructor
}
}
pmOBJECTObject.prototype = Object.create(PowerModeObject.prototype);
pmOBJECTObject.prototype.constructor = pmOBJECTObject();

pmSCENEScene = function(game) { };
pmSCENEScene.prototype = {
create: function() {
addObject(new pmOBJECTObject(game, 85, 402));
executeConstructors();
},
preload: function() {
}
}

pmOBJECTObject.prototype.pmDestroy2 = function() {
scene.removeObject(this);
}


//End Of PowerMode Functions


</script>
</head>
<body onload='init()'>
</body>
</html>

Link to comment
Share on other sites

/* This script was created by Oliver Scott-Brown for use with the game development software, PowerMode.
This script functions as the engine for PowerMode generated code
If this script is distributed to the public, it must legally be used ONLY with PowerMode compiled web apps

http://www.powermodegames.com
Copyright © 2014 Oliver Scott-Brown (check http://legal.powermodegames.com for legal details)*/


// declare variables
var game;

// functions to power the engine (excluding classes)
function executeConstructors() {
    for (var i = 0; i < game.stage.children.length; i ++) {
        game.stage.children.theConstructor = function() {}
        game.stage.children.theConstructor();
    }
}

function addObject(obj) {
    game.add.existing(obj);
    obj.animations.add('go');
    obj.animations.play('go', 1, true);
}

function loadSpriteSheet(name) {
    game.load.spritesheet(name, 'media/' + name + '.json');
}

//classes that are built-in to the PowerMode engine

var PowerModeObject = function(game, x, y) {
    Phaser.Sprite.call(this, game, x, y);
}
PowerModeObject.prototype = Object.create(Phaser.Sprite.prototype);
PowerModeObject.prototype.constructor = PowerModeObject;

Link to comment
Share on other sites

game.state.add('pmSCENEScene', game.pmSCENEScene);

try using this:

game.state.add('pmSCENEScene', pmSCENEScene);

this should solve the error "Phaser.StateManager - No state found with the key: pmSCENEScene" phaser.js:14293"

this is because 'game.pmSCENEScene' is not defined. 'pmSCENEScene' defined in the scope of the 'Init' function, but not in the 'game' object.

 

don't see '_this.boot' either. is this the whole source? try fixing the first error. may be the second will disappear.

Link to comment
Share on other sites

game.state.add('pmSCENEScene', game.pmSCENEScene);

try using this:

game.state.add('pmSCENEScene', pmSCENEScene);

this should solve the error "Phaser.StateManager - No state found with the key: pmSCENEScene" phaser.js:14293"

this is because 'game.pmSCENEScene' is not defined. 'pmSCENEScene' defined in the scope of the 'Init' function, but not in the 'game' object.

 

don't see '_this.boot' either. is this the whole source? try fixing the first error. may be the second will disappear.

 

I have changed this and I am still having problems

 

This is what Firefox says in the console:

 

TypeError: texture is undefined phaser.js:1717
ReferenceError: pmSCENEScene is not defined index.html:30
TypeError: _this.boot is not a function
 
Thanks
Link to comment
Share on other sites

hi oliversb,

 

The easiest way someone can check your code is if you put it up on the web, where it can directly be run.

(Including the assets (or some demo assets) that are loaded.)

 

Greetings,

JP

Link to comment
Share on other sites

Figured out the first problem.

 

The definition of pmSCENEScene does not work.

 

You need:

function pmSCENEScene(game) {};
but right now you have:
pmSCENEScene = function(game) { };

(That's just not the way to define a function, or in this case a constructor.)

 

 

This does not solve all problems, the game still won't start up.

Link to comment
Share on other sites

Here is the fixed file.

 

It still crashes, but only because you powermode object isn't really a sprite.. or something like that.

(Not a state problem anymore :) )

 

Fixes: "new", prototype fixes (more then the one posted above)

 

I have the strong feeling the wiki-tutorial is wrong at that point.

(how the prototype is setup. - From my understanding that's just not how it works.)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="content-type" content="text/html;charset=utf-8" /><title>as</title><script src="src/prototype.js" type="text/javascript"></script><script src="src/phaser.js" type="text/javascript"></script><script src="src/PowerModeEngine.js" type="text/javascript"></script><style type="text/css">body {background-color: #3B3B3B;font-family: arial, verdana, sans-serif;font-size: 12px;}#canvas{background-color: #FFFFFF;display: block;margin: 0 auto;}</style><script type="text/javascript">//End Of Variablesfunction init() {game = new Phaser.Game(640, 480, Phaser.AUTO, 'game');game.state.add('pmSCENEScene', pmSCENEScene);game.state.start('pmSCENEScene');}function pmOBJECTObject(x, y, sprite) {//pmOBJECTObjectPowerModeObject.call(this, game, x ,y);function theConstructor () {//pmOBJECTObjectConstructor}}pmOBJECTObject.prototype = Object.create(PowerModeObject.prototype);pmOBJECTObject.prototype.constructor = pmOBJECTObject();function pmSCENEScene(game) { }pmSCENEScene.prototype.create = function() {addObject(new pmOBJECTObject(game, 146, 372));executeConstructors();};pmSCENEScene.prototype.preload = function() {};pmOBJECTObject.prototype.pmDestroy2 = function() {scene.removeObject(this);};//End Of PowerMode Functions</script></head><body onload='init()'></body></html>
Link to comment
Share on other sites

  • 3 weeks later...
 Share

  • Recently Browsing   0 members

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