Titus

Members
  • Content count

    21
  • Joined

  • Last visited

About Titus

  • Rank
    Member

Contact Methods

  • Twitter
    turnerjordan855

Profile Information

  1. Overlap Between Emitter and Group

    @samme Excellent, thank you!
  2. Hi guys, just a quick question. I'm trying to detect overlap between emitter particles and a group like so: create: function() { this.emitter = this.game.add.emitter(0, 0, 1000); this.emitter.enableBody = true; this.emitter.makeParticles('whiteParticle'); this.emitter.minParticleSpeed.setTo(100); this.emitter.maxParticleSpeed.setTo(800); this.emitter.gravity = 50; this.emitter.maxParticleScale = 3; this.emitter.minParticleScale = 0.1; this.emitter.setYSpeed(-150, 150); this.emitter.flow(1500, 100, 100, -1, false); //lifespan, frequency, quantity, total, immediate this.emitter.checkWorldBounds = true; this.emitter.outOfBoundsKill = true; this.fire = this.game.add.group(); this.fire.enableBody = true; this.fire3 = this.game.add.sprite(1423, 500, 'fireL3'); this.fire2 = this.game.add.sprite(1423, 500, 'fireL2'); this.fire1 = this.game.add.sprite(1423, 500, 'fireL1'); this.fire.add(this.fire3); this.fire.add(this.fire2); this.fire.add(this.fire1); }, update: function(){ this.game.physics.arcade.overlap(this.emitter, this.fire, this.damageFire, null, this); } damageFire: function(){ console.log('fire damaged!'); }, I can get this to work fine if I check for overlap between 2 sprites/groups, but I cannot get it to work for the emitter. Could anyone point me in the right direction? Thanks
  3. Large Texture Atlas

    Thanks again @Skeptron. Have you used Spine yourself? I might have to give it another look if the current way are doing things is just too heavy. I've done a bit of research but it wasn't clear to me if it's possible to use Spine animations with Phaser.
  4. Large Texture Atlas

    @Skeptron Thanks for the suggestions. I really don't think that Spine or Spriter would be what I need. Mainly because my animations aren't really skeletal, except the player character, which I don't really have this issue with. I'm very new to game development but I've been tasked with creating this game primary for web browsers on PC but should to work for mobile devices. I have someone making the assets using Abode After Effects. It's a fire extinguisher simulation. An example here is I have a state that is shown for game over if the user selects the wrong type of extinguisher. The animation on that page shows the player (half body framing) getting electrocuted , but there isn't really any skeletal movement. I have exports of all the frames for a 3 second animation at 24fps. That gives me 70+ images that I put into an atlas using Texture Packer. Each export is 1920 x 1080 with the player taking up about 1/3 to 1/2 of that size. Texture packer does a decent job of packing them together in the atlas. I was hoping that I was just doing something wrong but I'm now assuming that I just have too many textures that are too big for Phaser (or maybe any html5 framework) to load well. Interestingly I have noticed quite a bit of improvement by changing the render type from Phaser.AUTO to Phaser.CANVAS. That has surprised me quite a bit.. I'm using a PC and it's not super high end but it has a GTX 750 Ti so I thought that webgl would offer the better performance for sure and I also read that webgl would be best for most mobile devices.
  5. Large Texture Atlas

    Hi Guys, I'm making a game that uses assets for a 1920 x 1080 screen and I'm having some issues with some states taking a long time to load. All my assets are loaded in a preload state which has a loading bar but the issue I'm having is that some states which access a large texture atlas (8,000 or higher) take 3-5 seconds to load, without any feedback to the user. I wouldn't mind if that extra time was added to the preload state with a loading bar but I'm confused as to why switching states takes so long if the assets are already loaded. I've run some tests with simply adding a single sprite to a page in a create function from a large texture atlas. The texture atlas is 7643 x 8488 (2.94MB) and I've used Texture Packer to create the png and JSON array. The atlas contains around 70 textures. create: function(){ this.game.stage.backgroundColor = "#db6565"; this.test = this.game.add.sprite(400, 50, 'wrongFoam'); } This state takes around 2-3 seconds to load after pressing the next button in the previous state. Am I doing something wrong here? I can't split the textures into multiple atlases because I need access all 70 textures for certain animations. I also don't believe that Phaser supports multipack from Texture Packer. Any help would be appreciated. Thanks
  6. attach an emitter as child of sprite

    @samme Thanks you. That was very helpful. I had tried using the update function to attach the emitter to another sprite but I was using this.emitter.x instead of this.emitter.emitX and it didn't work. Interestingly when debugging the emitter (I had to use children[1] to get any debug info) I get coordinates of the first particle when it is not a child. As soon as I add it as a child of a sprite there is no debug information. Do you think there could be a bug in the current version of phaser?
  7. Hi Guys, I'm having some issues with an emitter that I am trying to attach to a sprite using the addChild method. The emitter should be a child of the player's arm so that it moves and rotates correctly. When I add the emitter to the game without being added as a child it works fine. As soon as I add it as a child to the arm it disappears from the game world. I've played around with a bunch of different coordinates in case it was being moved slightly off screen but I've come to the conclusion that something is going wrong here. I've also run tests in a new state with just a single sprite and an emitter and as soon as I add the emitter asChild of the sprite it is gone. I'm probably missing the thing that is going wrong here, so any help would be appreciated. I'll put my code snippet below if that helps at all create: function() { this.game.stage.backgroundColor = "#000"; this.playerContainer = this.game.add.sprite(300, 600, null); this.player = this.game.add.sprite(0, 0, 'player'); this.player.scale.setTo(0.75); this.backArm = this.game.add.sprite(-10, -180, 'backArm'); this.backArm.scale.setTo(0.75); this.frontArm = this.game.add.sprite(-10, -180, 'frontArm'); this.frontArm.scale.setTo(0.75); this.emitter = this.game.add.emitter(0, 0, 5000); this.emitter.makeParticles('whiteParticle'); this.emitter.minParticleSpeed.setTo(200, 0); this.emitter.maxParticleSpeed.setTo(2000, 0); this.emitter.gravity = 200; this.emitter.lifespan = 0; this.playerContainer.addChild(this.backArm); this.playerContainer.addChild(this.player); this.playerContainer.addChild(this.frontArm); this.frontArm.addChild(this.emitter); this.game.physics.arcade.enable(this.playerContainer); this.game.physics.arcade.enable(this.player); this.playerContainer.body.collideWorldBounds = true; this.player.anchor.setTo(0.5); this.frontArm.anchor.setTo(0.4866, 0.2925); this.backArm.anchor.setTo(0.4866, 0.2925); },
  8. child sprite behind parent

    @samid737 That worked perfectly! I think I had tried that initially but got some errors (probably because I had mistakenly changed the walk animation code to the container too). Thanks once again for the help.
  9. child sprite behind parent

    Hi Guys, I'm trying to link 3 sprites together for a player character using the addChild method on a sprite. I have backArm, player and frontArm sprites that need to be rendered in that order. The arms both rotate at the shoulder and the backArm needs to go behind the player sprite. I've seen a suggestion on this thread to have a main sprite container with a null key and add the sprites as children of that. I've tried that and I have my sprites rendered in the correct order but the arms do not follow the player anymore when it walks across the screen. The arms just stay in place while the player walks away. Pretty sure I've made an error somewhere. I'll put a code snippet below and any advice would be really helpful. Thanks create: function() { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.playerContainer = this.game.add.sprite(200, 500, null); this.backArm = this.game.add.sprite(0, 500, 'backArm'); this.player = this.game.add.sprite(200, 500, 'player'); this.frontArm = this.game.add.sprite(0, 500, 'frontArm'); this.playerContainer.addChild(this.backArm); this.playerContainer.addChild(this.player); this.playerContainer.addChild(this.frontArm); this.game.physics.arcade.enable(this.player); this.player.anchor.setTo(0.5); this.frontArm.anchor.setTo(0.4866, 0.2925); this.backArm.anchor.setTo(0.4866, 0.2925); //walk animation this.player.animations.add('walkright', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 0, 24,'', 5), 24, true, false); this.player.animations.add('walkleft', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 24, 0,'', 5), 24, true, false); cursors = this.game.input.keyboard.createCursorKeys(); }, update: function() { //player walk movement this.player.body.velocity.x = 0; if (cursors.right.isDown) { this.player.body.velocity.x = 150; this.player.animations.play('walkright'); }else if (cursors.left.isDown){ this.player.body.velocity.x = -150; this. player.animations.play('walkleft'); }else { this.player.animations.stop(); this.player.frame = 25; } this.frontArm.rotation = this.game.physics.arcade.angleToPointer(this.frontArm.world); this.backArm.rotation = this.game.physics.arcade.angleToPointer(this.backArm.world); }
  10. angleToPointer on child sprite

    @samid737 That worked. Thanks so much!
  11. angleToPointer on child sprite

    Hi guys, I'm trying to rotate a player's arm (anchored at the shoulder) to the mouse pointer using angleToPointer() method for aiming. I have a player sprite and a frontArm sprite. angleToPointer works as expected until I make the frontArm sprite a child of the player sprite. When I do this, the frontArm sprite will get stuck at certain points and won't rotate any further. I'm a complete newbie to Phaser and game dev so any help would be appreciated. I'll put my code below: create: function() { this.background = this.game.add.sprite(0, 0, 'background'); this.game.physics.startSystem(Phaser.Physics.ARCADE); this.player = this.game.add.sprite(200, 500, 'player', 'Fire Marshall Main_00025'); this.game.physics.arcade.enable(this.player); this.player.anchor.setTo(0.5); this.frontArm = this.player.addChild(this.game.make.sprite(-10, -240, 'frontArm')); this.frontArm.anchor.setTo(0.48, 0.30); this.game.physics.arcade.enable(this.frontArm); //walk animation this.player.animations.add('walkright', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 0, 24,'', 5), 24, true, false); this.player.animations.add('walkleft', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 24, 0,'', 5), 24, true, false); cursors = this.game.input.keyboard.createCursorKeys(); }, update: function() { //player walk movement this.player.body.velocity.x = 0; if (cursors.right.isDown) { this.player.body.velocity.x = 150; this.player.animations.play('walkright'); }else if (cursors.left.isDown){ this.player.body.velocity.x = -150; this. player.animations.play('walkleft'); }else { this.player.animations.stop(); this.player.frame = 25; } this.frontArm.rotation = this.game.physics.arcade.angleToPointer(this.frontArm); }
  12. Animation Taking a Long Time to Load

    @Skeptron Thanks for the reply. I used Texture Packer to create the spritesheets and they are quite large (Around 8000 x 5000). There are 5 animations on the page that play for 5 seconds (@60fps) on a loop so each spritesheet has 300 .pngs. It is probably just overkill but I was hoping I could somehow add the animations in the preload state and pass them through to a new state so the additional time required to create the animations would have a progress bar. I've very new to Phaser though so I have limited knowledge. I've had a quick look at Spine but I don't think that would be what I'm looking for. I might just have to bump the framerate down and have smaller spritesheets.
  13. Hi Guys, I'm currently making a game and I've run into a bit of an issue with one of the states that is loading multiple animations. There are 5 animations in total that play as soon as the state loads. They also loop. The problem that I'm having is that the state with the animations is taking around 5+ seconds to load, even though the spritesheets have been loaded in the Preload State. I feel this might be because the animations are being set so 60 FPS. I would prefer it if I could add this extra loading time to the Preload State if possible (because it has a loading bar) so I was wondering if there is a way to create the animations in a previous state and then have them play instantly on the page I need them to. Any help would be appreciated.
  14. Can't create new objects in phaser group

    I'm also new to Phaser but when I tested your code I was able to add both 'devil' sprites to the game world so maybe something else is affecting it, but you could try putting the sprite into a variable and then add it to the group function create (){ capetinhas = game.add.group(); game.add.sprite(window.width,0,'tabuleiro');//loading the background var devil = game.add.sprite(128,128,'devil'); capetinhas.add(devil); }
  15. Define Game Scaling at Boot

    @samme Thanks for the reply. You are correct. I'm not sure what was going on yesterday but today I've tested it again and the scaling defined at boot is being applied to the rest of the game. I think I might have had some images cached.