lewster32 / phaser-plugin-isometric

Feature-packed axonometric plugin for Phaser 2 which stays true to the Phaser API.
http://rotates.org/phaser/iso
MIT License
472 stars 163 forks source link

Added Support for Typescript #12

Closed edgarjcfn closed 9 years ago

edgarjcfn commented 9 years ago

As explained on this Thread the approach of extending the behaviour of Phaser's core classes by adding methods and properties to them, makes the game incompatible with Typescript. That's because it's not possible in Typescript to merge class definitions.

This pull request solves this problem by adding references that are not extending Phaser's core classes. More specifically

  1. Added a property to projector where it was before accessed by game.iso
  2. Added a method addIsoSprite() where it was before accessed by game.add.isoSprite

The other important addition is the inclusion of phaser.plugin.isometric.d.ts file with Typescript Definitions. It's still not complete, but should be enough to run the examples on the website.

lewster32 commented 9 years ago

Excellent, simple fixes too - thanks a lot!

clark-stevenson commented 9 years ago

This is Amazing :dancer:

I will take a look at padding out this d.ts file this weekend, most of it was done when I noticed the original problem.

Thanks! It was killing me.

MisterJack49 commented 7 years ago

Hi, I'm new to typescript/Phaser and I'm trying to convert the example from the website "Pointer interaction" to typescript but I'm blocking on how to replace game.iso by projector and game.add.isoSprite by addIsoSrpite.

My preload look like this :

preload() {
    this.game.plugins.add(Phaser.Plugin.Isometric);
    this.game.iso.anchor.setTo(0.5, 0.2);
}

and spawnTiles :

spawnTiles() {
    var tile;
    for (var xx = 0; xx < 256; xx += 38) {
        for (var yy = 0; yy < 256; yy += 38) {
            tile = this.game.add.isoSprite(xx, yy, 0, 'tile', 0, this.isoGroup);
            tile.anchor.set(0.5, 0);
         }
    }
}