Huggz Posted March 15, 2015 Share Posted March 15, 2015 I'm having a bit of an issue porting a project from typescript to plain old javascript. Looking in my old game.js file (generated by the TS complier) and I grabbed the following pieces of code and placed them into files stated below. However when I try to run my page, I get the following error: Uncaught TypeError: Cannot read property 'call' of undefined phaser.js:45167 Looking into it, it appears that my Game object is being added to Phaser's readyCheck without a boot callback, but I don't understand why. I literally copied this code out of my working game file and pasted it into a new file and now it doesn't want to work. I can verify that __extends is defined correctly at runtime, Game has indeed extended the Phaser.Game prototype, and Game.prototype.boot is assigned the appropriate function, after __extends returns. I'm kinda confused and am totally prepared for this to be something dumb, but I could use some assistance here. Thank you utilities.jsvar __extends = this.__extends || function (d, { for (var p in if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __();};app.jsvar MyGame;(function (MyGame) { var Game = (function (_super) { __extends(Game, _super); function Game() { _super.call(this, 1024, 768, Phaser.AUTO, 'content', null); //this.state.add('Boot', MyGame.Boot, false); //this.state.add('Preloader', MyGame.Preloader, false); //this.state.add('Play', MyGame.Play, false); //this.state.start('Boot'); } return Game; })(Phaser.Game); MyGame.Game = Game;})(MyGame|| (MyGame = {}));// Start the gamewindow.onload = function () { var game = MyGame.Game(); };index.html<div id="content"></div><script src="/Scripts/Phaser/phaser.js"></script><script src="/Scripts/Game/utilities.js"></script><script src="/Scripts/Game/app.js"></script> Link to comment Share on other sites More sharing options...
Huggz Posted March 15, 2015 Author Share Posted March 15, 2015 Ah... I found it. Wasn't instantiating the prototype, so naturally, the prototype methods will not exist :-p window.onload = function () { var game = new MyGame.Game(); }; Link to comment Share on other sites More sharing options...
Recommended Posts