PMayhem Posted December 22, 2014 Share Posted December 22, 2014 I'm stuck with 2 last issues with my first platformer game. ***EDIT***Here's a link for referencehttp://projectmayhem.co.uk/sandbox/santa/santa.html I can't get all of my snowmen to shoot, and also I can't seem to remove the 'kill' animation when a snowman dies.Any suggestions would be really helpful. I'm creating enemy snowmen and adding them to a group So I'm defining and creating the snowmen group then adding each snowman in the create with grpSnowmen = this.game.add.group();this.spawnSnowman(800,200, 'snowman1');Which calls the following, adding a new snowman to the group spawnSnowman: function(x,y,name){ var snowman = this.game.add.sprite(x,y, 'snowman'); this.game.physics.arcade.enable(snowman); snowman.name = name; snowman.isAlive = true; snowman.health = 1; snowman.pathcount = 1; snowman.enableBody = true; snowman.body.gravity.y = 500; snowman.body.collideWorldBounds = true; snowman.animations.add('walking_left', [0,2], 6, true); snowman.animations.add('walking_right', [1,3], 6, true); grpSnowmen.add(snowman); return snowman; } Next, in the update, I'm cycling through the group and if the snowman is alive, I'm updating it's path and calling fire functions ala: grpSnowmen.forEach(function(snowman) { if(snowman.isAlive){ this.snowmanPath(snowman); this.enemyShoots(snowman); } }, this); All of the snowmen move correctly, however only the very first snowman firesHere are the snowmanPath and EnemyShoots functions snowmanPath: function(enemySnowman) { if (this.pathCounter < 325) { enemySnowman.animations.play('walking_right'); enemySnowman.body.velocity.x = 100; enemySnowman.facingEnemy = 'right'; } else { enemySnowman.animations.play('walking_left'); enemySnowman.body.velocity.x = -100; enemySnowman.facingEnemy = 'left'; } } enemyShoots: function(thisSnowMan) { obj = thisSnowMan; if (this.shotTimerEnemy < this.game.time.now && thisSnowMan.isAlive == true) { this.shotTimerEnemy = this.game.time.now + 3000; if (thisSnowMan.facingEnemy == 'right') { this.snowball = snowballs.create(thisSnowMan.body.x + thisSnowMan.body.width / 2 + 45, thisSnowMan.body.y + thisSnowMan.body.height / 2 + 5, 'snowball'); } else { this.snowball = snowballs.create(thisSnowMan.body.x + thisSnowMan.body.width / 2 - 40, thisSnowMan.body.y + thisSnowMan.body.height / 2 + 5, 'snowball'); } this.game.physics.enable(this.snowball, Phaser.Physics.ARCADE); this.snowball.body.gravity.y = 300; this.snowball.body.bounce.y = 10; this.snowball.outOfBoundsKill = true; this.snowball.anchor.setTo(0.5, 0.5); this.snowball.body.velocity.y = -160; if (thisSnowMan.facingEnemy == 'right') { this.snowball.body.velocity.x = 400; } else { this.snowball.body.velocity.x = -400; } } } Link to comment Share on other sites More sharing options...
PMayhem Posted December 24, 2014 Author Share Posted December 24, 2014 anyone? dust? anyone? Or is there a way I can debug a single snowman and see all of it's properties, not just the standard positioning but the custom properties? Link to comment Share on other sites More sharing options...
Recommended Posts