• Content Count

  • Joined

  • Last visited

Everything posted by ghclark2

  1. Quote from container docs: When the Container is rendered, all of its children are rendered as well, in the order in which they exist within the Container. Container children can be repositioned using methods such as MoveUp, MoveDown and SendToBack
  2. Hi, I've added a particle manager to a container and created three emitters within it. The first emitter appears to inherit its position from the container as you'd expect, but the second and third emitters seem to be doing something weird in terms of positioning. I could try adding three managers each with one emitter, but was wondering if there was a reason why the three emitters in one manager doesn't work... Thanks, Gordon 'this' in the context below is the container. addEngines() { // create attached particle emitter this.particles = this.scene.add.particles('particleBlue') .setDepth(this.depth + 1); this.add(this.particles); this.emitterBottom = this.particles.createEmitter({ x: -19, y: 10, scale: { start: 0.5, end: 0 }, blendMode: 'ADD', frequency: 25, speed: 25, }); this.emitterTop = this.particles.createEmitter({ x: -19, y: -10, scale: { start: 0.5, end: 0 }, blendMode: 'ADD', frequency: 25, speed: 15, }); this.emitterFront = this.particles.createEmitter({ x: 20, y: -20, scale: { start: 0.5, end: 0 }, blendMode: 'ADD', frequency: 25, speed: 35, }); }
  3. I want to able to render fractions (e.g. 1/4, 2/3, 3/8, 3/2) in my game that the player can drag to a line. I'm wanting more fractions than the typical ones, e.g. 5/2, and I'm wanting to be able to generate them from within phaser. Anyone got a good idea of maybe how to do this. Was wondering about using an html file as that would give me super and sub scripts, but that would require a file for each fraction. Thanks, Gordon
  4. 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
  5. 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,,; } }; 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
  6. 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.collisionLayer, this.shotCollisionLayer, null, this);, 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.collisionLayer, this.shotCollisionLayer, null, this);, this.player, this.shotPlayer, null, this); Many thanks, Gordon
  7. 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 =, '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); The error is: phaser.js:100951 Uncaught TypeError: Cannot read property 'width' of undefined at (phaser.js:100951) It seems to be an issue with the context, but I have tried this.weapon, this.state, all to no avail. Annoyingly if I run from the console it shoots fine. If anyone can see what I'm doing wrong I'd be very grateful. Thanks, Gordon
  8. 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