Hi Everyone! I'm really new to phaser, and coding in general, I only know a few bits and pieces of different languages and stuff.
I have been trying to figure out how to make a simple, space ships destroy astroid game Using Phaser Editor 1.5.3 and ARCADE PHYSICS. But I have quickly run into a problem. Whenever I try to add velocity or anything like that to my game. I get this weird error outputted in the inspect element console. It said,
Uncaught ReferenceError: game is not defined
at Level.create (Level.js:44)
at Phaser.StateManager.loadComplete (phaser.js:30083)
at Phaser.Loader.finishedLoading (phaser.js:74233)
at Phaser.Loader.processLoadQueue (phaser.js:74190)
at Phaser.Loader.asyncComplete (phaser.js:74263)
at Phaser.Loader.fileComplete (phaser.js:75120)
at Image.file.data.onload (phaser.js:74522)
I tried to copy other examples and things, but a lot of them seem to use a different structure in the coding. With less State/Canvas/Js files. It all just seems to be coded in one large file.
These are my files:
Index.html:
<!DOCTYPE HTML>
Astroids
Main.js:
window.onload = function() {
var game = new Phaser.Game(800, 600, Phaser.AUTO);
// Add the States your game has.
// game.state.add("Boot", Boot);
// game.state.add("Menu", Menu);
// game.state.add("Preload", Preload);
game.state.add("Level", Level);
game.state.start("Level");
/ --- end generated code --- /
// -- user code here --
Level.prototype.update = function() {
};
---------------------
Aside from all that I was wondering what actually executes the functions: Create, Preload, Init, Update, and Render. What their main purpose is, (especially the last three) and what the whole "prototype" thing is about.
Hi Everyone! I'm really new to phaser, and coding in general, I only know a few bits and pieces of different languages and stuff.
I have been trying to figure out how to make a simple, space ships destroy astroid game Using Phaser Editor 1.5.3 and ARCADE PHYSICS. But I have quickly run into a problem. Whenever I try to add velocity or anything like that to my game. I get this weird error outputted in the inspect element console. It said,
Uncaught ReferenceError: game is not defined at Level.create (Level.js:44) at Phaser.StateManager.loadComplete (phaser.js:30083) at Phaser.Loader.finishedLoading (phaser.js:74233) at Phaser.Loader.processLoadQueue (phaser.js:74190) at Phaser.Loader.asyncComplete (phaser.js:74263) at Phaser.Loader.fileComplete (phaser.js:75120) at Image.file.data.onload (phaser.js:74522)
I tried to copy other examples and things, but a lot of them seem to use a different structure in the coding. With less State/Canvas/Js files. It all just seems to be coded in one large file. These are my files:
Index.html:
<!DOCTYPE HTML>
Main.js:
window.onload = function() { var game = new Phaser.Game(800, 600, Phaser.AUTO);
};
Leve.jsl
// -- user code here --
/ --- start generated code --- /
// Generated by 1.5.3 (Phaser v2.6.2)
/**
Level. */ function Level() {
Phaser.State.call(this);
}
/* @type Phaser.State / var Level_proto = Object.create(Phaser.State.prototype); Level.prototype = Level_proto; Level.prototype.constructor = Level;
Level.prototype.init = function () {
};
Level.prototype.preload = function() {
};
Level.prototype.create = function(){
};
/ --- end generated code --- / // -- user code here --
Level.prototype.update = function() {
};
---------------------
Aside from all that I was wondering what actually executes the functions: Create, Preload, Init, Update, and Render. What their main purpose is, (especially the last three) and what the whole "prototype" thing is about.
Thanks so much for your time Blue