ArmTwo

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. Hi @samme, the problem is that the typescript accuses error, saying that the property not exists. But works anyway. could have a conditional for check if this.bullets is null. i looked the Phaser CE and it have this: //prevent crash if weapon's bullets have not yet been initialized if (this.bullets) { this.bullets.classType = this._bulletClass; }
  2. Hi, In the documentation of the Weapon, the property bulletClass speak the follow: bulletClass : Object => "The Class of the bullets that are launched by this Weapon. Defaults Phaser.Bullet, but can be overridden before calling createBullets and set to your own class type." that could be written: class MyWeapon extens Phaser.Weapon { contructor(){ super(); this.bulletClass = MyBulletClass; /*error here*/ this.createBullets(30, imgSprite); } } the problem is that que the method bulletClass executes internally the code: https://github.com/photonstorm/phaser/blob/v2.6.2/src/plugins/weapon/WeaponPlugin.js#L1130 this.bullets.classType = this._bulletClass; But this.bullets still not was instantiate(null), so throws the error "can not read property 'classType' of undefined". If i comments the line, everything works. Would this line really necessary? I'm using Phaser 2.6.2.
  3. thanks @samme, works like a charm. I just has needed of add the method init(), because the constructor of the MissileWeapon receive two args. before: class MissileWeapon extends Phaser.Weapon { someVar: string; constructor(game: Phaser.Game, someVar: string){ super(game, game.plugins); this.someVar = someVar; /*the hack*/ this.active = true; /*active plugin*/ this.hasUpdate = true; var test = game.plugins.add(Phaser.Weapon); /*Only for the game.plugins(PluginManager) start running*/ game.plugins.plugins.push(this); /*add my weapon in the PluginManager*/ } } //level01.ts this.myMissileWeapon = new MissileWeapon(this.game, "something"); now: class MissileWeapon extends Phaser.Weapon { someVar: string; constructor(game: Phaser.Game, parent: Phaser.PluginManager){ super(game, game.plugins); } init(someVar: string){ this.someVar = someVar; } } //level01.ts this.myMissileWeapon = this.game.plugins.add(MissileWeapon, "something");
  4. Hi, I'm writing a class that extends Phaser.Weapon and i want that the method update() keep running, like this: class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); } update(){ /*this not execute*/ } } But it not running. If i add this "hack": class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); /*the hack*/ this.active = true; /*active plugin*/ this.hasUpdate = true; var test = game.plugins.add(Phaser.Weapon); /*Only for the game.plugins(PluginManager) start running*/ game.plugins.plugins.push(this); /*add my weapon in the PluginManager*/ } update(){ /*executing */ } } It seems that when extends of plugin Weapon, it not is added direct in the game.plugins (PluginManager), then the method update not executes. How could i make this without uses the "hack"? and i'm using Phaser version 2.6.2 thanks :-)