ghclark2

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. ghclark2

    SVG and tilemaps

    Hi, one of the things I was excited about for phaser 3 was the possibility of using svgs to make really crisp good looking games. Just wondering though whether there is any way of using svgs for a tilemap, or is there another way of getting good looking tilemaps without huge filesizes? Thanks, Gordon
  2. Many thanks Daniel and Samme - have gone with option 2 for the collision checks. To sort out the autofire issue, I have ended up giving the weapon an extra property of 'target' which is a reference to either the player or enemy that is beign fired at and then hacking the weapon's update method to: // this is a hack of a protected method in order to make the weapon autofire at the target. ZPlat.WeaponBlast.prototype.update = function () { if (this._bulletKillType === Phaser.Weapon.KILL_WEAPON_BOUNDS) { if (this.trackedSprite) { this.trackedSprite.updateTransform(); this.bounds.centerOn(this.trackedSprite.worldPosition.x, this.trackedSprite.worldPosition.y); } else if (this.trackedPointer) { this.bounds.centerOn(this.trackedPointer.worldX, this.trackedPointer.worldY); } } if (this.autofire) { // ONLY LINE CHANGED this.fire(null, this.target.x, this.target.y); } }; Since weapons already have the ability to track a Sprite to get the fireFrom position, I wonder if it would be useful for them to have an optional targetSprite / targetPointer property so they can track for the fireAt position as well... Thanks, Gordon
  3. In my platformer, the player has a number of different weapons (gun, energy blast, homing missile) and there may be a number of enemies (up to maybe 6) who will have one of the same weapons. From my understanding of the weapon plugin and tutorials, I should then be making a different weapon object for each of the players weapons and for each enemy. As I am wanting to attach a particle emitter to missiles I'm then going to extend the bullet class to make a missile. Question 1: I want autofire from enemies to fireAtSprite rather than just fire, I'm assuming the best way to do this is to extend the weapon class and overwrite the fire() method to call fireAtSprite() instead? Or is there a better way? Question 2: Where do I put the collision checks for the bullets? I can see a couple of options but would really like to know the performance implications as to which would be better. 1) Put an arcade collision call in the extended bullet update method to handle hitting scenery and hitting enemies - this seems neat in some ways as the code for the bullet hitting something sits with the bullet itself, however it feels like I'm going to end up with a lot of separate collision calls. 2) Put an arcade collision call in the state update along the lines of: this.enemies.forEach(function(enemy){ this.game.physics.arcade.collide(enemy.weapon.bullets, this.collisionLayer, this.shotCollisionLayer, null, this); this.game.physics.arcade.collide(enemy.weapon.bullets, this.player, this.shotPlayer, null, this); }, this); 3) In the custom bullet constructor, add all enemy bullets to an enemyBulletsArray and collide this in the state update method this.game.physics.arcade.collide(this.enemyBulletsArray, this.collisionLayer, this.shotCollisionLayer, null, this); this.game.physics.arcade.collide(this.enemyBulletsArray, this.player, this.shotPlayer, null, this); Many thanks, Gordon
  4. ghclark2

    what context to pass for weapon.fire function

    That's great - many thanks!
  5. Hi, I am really confused why I am getting errors with this code from the weapon plugin: create: function() { //load current level this.loadLevel(); this.weapon = this.game.add.weapon(-1, 'explode'); this.weapon.fireFrom.setTo(300,300, 1, 1); this.weapon.bulletKillType = Phaser.Weapon.KILL_CAMERA_BOUNDS; this.weapon.bulletGravity.y = -1000; this.input.keyboard.addKey(Phaser.KeyCode.SPACEBAR) .onDown.add(this.weapon.fire, this); The error is: phaser.js:100951 Uncaught TypeError: Cannot read property 'width' of undefined at Object.Phaser.Weapon.fire (phaser.js:100951) It seems to be an issue with the context, but I have tried this.weapon, this.state, this.game all to no avail. Annoyingly if I run ZPlat.GameState.weapon.fire() from the console it shoots fine. If anyone can see what I'm doing wrong I'd be very grateful. Thanks, Gordon
  6. Hi, I'm currently in the process of making my first game having completed the zenva course and am confused by the weapon plugin. My game is a platformer shootemup type, where there will be the player and multiple enemies shooting a variety of ammo types. The zenva course covers making bulletpools and sharing them between enemy sprites, but does not mention the weapon plugin. On the face of it the weapon plugin looks great, sorting out a whole load of features neatly. However if each enemy has its own weapon tracking it, does that mean that it then gets its own bullet pool, all of which then need to be destroyed once the enemy is killed? This seems to somewhat defeat the point of the bullet pool. My question is then: can the bullet pools be shared between enemies OR should I just rely on the entire bulletpool being recycled along with the enemy itself as it is itself pooled OR should I just not bother with the weaponplugin at all? Any help or suggestions much appreciated, Thanks, Gordon