KoalaForce Posted July 7, 2015 Share Posted July 7, 2015 I'm trying to extend the Phaser.Image class in Typescript so I can create some buttons for my UI, and remove some clutter from my main js file. IE:exitButton.anchor.setTo(0.5, 0.5);exitButton.inputEnabled = true;exitButton.visible = true;tovar exitImage = new ButtonImage(this.game, (this.scale.width -this.yGridMargin), this.scale.height, 'buttonSheet', 5);When I run the game chrome and firefox return this.game is null or cannot read property cache of null.The console seems to be point to line 35779 in the phaser.js file.else if (typeof key === 'string' && !this.game.cache.checkImageKey(key))ButtonImage///<reference path = "../tsDefinitions/phaser.d.ts" />module BasicGame{ export class ButtonImage extends Phaser.Image{ constructor(game: Phaser.Game, x:number, y:number, key:any, frame: number | string){ //constructor(x: number, y:number, key: any | 'string', frame: number | string){ super(this.game, x, y, key, frame); this.anchor.setTo(0.5, 0.5); this.inputEnabled = true; this.visible = true; //game.add.existing(this); } } }Any help is much appreciated. *edit for language context Link to comment Share on other sites More sharing options...
drhayes Posted July 7, 2015 Share Posted July 7, 2015 I'm totally not a TypeScript person... but should that super call have "this.game" in it? Isn't "game" assigned to "this.game" in the super's ctor? KoalaForce 1 Link to comment Share on other sites More sharing options...
KoalaForce Posted July 7, 2015 Author Share Posted July 7, 2015 You are totally an OOP person though! Should have been:super(game, x, y, key, frame);Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts