Vignarg Posted November 5, 2015 Share Posted November 5, 2015 One thing I continually struggle with in Phaser w/ Typescript is referencing a function in another file. Any help in this area would be greatly appreciated. Below is a simplified example of what I'm trying to do. module myModule { export class ClassA extends Phase.State { ... this.returnText.events.onInputDown.add(this.backToWorldMap, this); // this works // this.returnText.events.onInputDown.add(Navigation.backToWorldMap(), this); <- I want this to work! } backToWorldMap() { this.game.state.start('worldMap', true, false); <--- I want this moved. }}in another file:module myModule{ export class Navigation { backToWorldMap() { this.game.state.start('worldMap', true, false); } }}I've tried having Navigation extend Phaser.Game and playing with intellisense to figure out what it "wants". myModule.Navigation.prototype will at least show the functions in the target class, but then when I go to compile, it falls apart. As a side note, if anyone has any website or guides that use Phaser with Typescript they could share, I'd be very grateful. I've followed gamesfromscratch and photonstorm's guides, but they really don't get into things like the above. And Interphase is more focused on using specific features of phaser, using a simple game form that avoids this stuff. I haven't had any luck finding a happy middle ground of "great, you got the basics, now lets talk architecture and the syntax to make it work." As always, thanks in advance for any assistance. You guys are awesome. I don't know why I've waited to long to just ask for help on this. Link to comment Share on other sites More sharing options...
Recommended Posts