Really annoyed at this engine I'm writing, but that's fine, that's what Stack Overflow is for. So I have all my game "Entities" prototyping from an object:
function Scene(name, description) { // Initialize the Scene Object
/* VARIABLES */
this.entities = [];
/* METHODS */
};
Scene.prototype.addEntitiy = function(entity) { // Add an entity to this scene
this.entities.push(entity);
}
I have removed non-essential code (other Variables and Methods) for simplicity sake. As you can see, Scene is prototyping addEntity(entity). I instantiate TWO Scene objects (Scene1, Scene2) later in code. Scene1 doesn't seem to have a problem. Here is Scene2:
// Scene Two
var Scene2 = new Scene('Play Game', 'Actual game screen for playing Pong!');
Scene2.addEntity(GameBall);
Engine.scenes.push(Scene2);
Engine.scenes holds all scenes. Again, no errors at all with Scene1 (new Scene with one addEntity call). Scene two, however, insists this:
TypeError: Scene2.addEntity is not a function
Wtf, worked fine for Scene1? Also, Scene2 worked fine until I added a second entity to load (theoretically "identical" to the GameBall except for a few variable values). So, for thoroughness, I commented out the new entity as soon as the error showed up. Still not a function. I removed the new (offending?) line completely, still not a function. It's been like that ever since. Chrome and Firefox both report it's not a function.
Thank you in advance.
You mis-spelled addEntitiy
.
that was easy