Search the Community

Showing results for tags 'kill'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 15 results

  1. Group of enemies don't take damage

    Hello! I have a group of enemies following the player, and I want when they are overlapping with the player and I press Q they take an amount of damage setted before. this is the part of the create function where I create the group this.enemies =; this.enemies.enableBody = true; this.enemies.setAll('body.immovable', true); this.enemies.createMultiple(5,"vikingo") this.enemies.children[0,1,2,3,4].health = 100; console.log(this.enemies.children[0,1,2,3,4].health) Here's the function I'm trying to use. Before I used the same syntax with a single sprite and went perfectly. In this case the console throws "Uncaught ReferenceError: i is not defined" matar: function(){ if(this.player.scale.x == 1 && this.Q.justDown && game.physics.arcade.overlap(this.player, this.enemies)) { this.enemies.children[i].damage(25); game.physics.arcade.moveToXY(this.enemies.children[i],15,2500,-300,0) console.log(this.enemies.children[i].health) } if(this.player.scale.x == -1 && this.Q.justDown && game.physics.arcade.overlap(this.player, this.enemies)){ this.enemies.children[i].damage(25); game.physics.arcade.moveToXY(this.enemies.children[i],-15,-2500,300,0) console.log(this.enemies.children[i].health) } }, I tested some other ways like changing children with children[0,1,2,3,4] but instead of throwing error I get "health = 100" all the time.
  2. Phaser Kill freezing game

    Hi I have an issue in my game.js these are snippets from the entire code where bullets and enemies overlap, but when they overlap the game crashes?: create : function(){ this.enemies =; this.enemies.enableBody = true; for (var i = 0; i < 1; i++) { var s = this.enemies.create(,, 'enemy1'); = 'enemy1' + s; s.body.collideWorldBounds = true; s.body.bounce.setTo(0.1, 0.1); s.animations.add('walk', [0, 1,]);'walk', 6, true); s.body.velocity.setTo(5 + Math.random() * 40, 5 + Math.random() * 40); } { var f = this.enemies.create(,, 'enemy2'); 'enemy2' + f; f.body.collideWorldBounds = true; f.body.bounce.setTo(0.1, 0.1); f.animations.add('walk', [0, 1,]);'walk', 6, true); f.body.velocity.setTo(5 + Math.random() * 40, 5 + Math.random() * 40); } } update: function() { game.physics.arcade.overlap(this.bullet, this.enemies, this.enemyKill, null, this); enemyKill: function(){ this.enemies.kill(); this.score += 10; this.scoreText.text = 'score: ' + score; }, Thanks
  3. Forewarning: semi-newbie Basically, if the user has the left cursor down and a "token" collides with the lftRect, I want to kill the token. For some reason my kill callback function for the collision is not working (below is relevant code): gumballGoGo.Preloader = function(game){ this.player = null; this.ground = null; //this.tokens = null; this.ready = false; }; var cursors, lftInit, rghtInit, ground, testDrp, sprite, tokens, rect, lftRect, ctrRect, rghtRect, lftToken; var total = 0; function lftHit(lftRect, lftToken) { if ( lftInit == true ){ lftToken.kill() } }; gumballGoGo.Preloader.prototype = { preload: function(){ }, create: function() { // LFT BOX lftRect = this.add.sprite(0, - 150, null); this.physics.enable(lftRect, Phaser.Physics.ARCADE); lftRect.body.setSize(100, 100, 0, 0); // CNTR BOX ctrRect = this.add.sprite(100, - 150, null); this.physics.enable(ctrRect, Phaser.Physics.ARCADE); ctrRect.body.setSize(100, 100, 0, 0); // RGHT BOX rghtRect = this.add.sprite(200, - 150, null); this.physics.enable(rghtRect, Phaser.Physics.ARCADE); rghtRect.body.setSize(100, 100, 0, 0); // INIT TOKEN GROUP tokens =; tokens.enableBody = true; this.physics.arcade.enable(tokens); testDrp = tokens.create(125, -50, 'token'); testDrp.body.gravity.y = 300; // CONTROLS this.cursors = this.input.keyboard.createCursorKeys(); }, update: function() { this.ready = true; if (this.cursors.left.isDown) { lftInit = true; } else if (this.cursors.right.isDown) { rghtInit = true; } else { lftInit, rghtInit = false; } if (total < 20) { tokenSpawn(); } this.physics.arcade.collide(lftRect, lftToken, lftHit, null, this); } }; function tokenSpawn() { lftToken = tokens.create(25, -(Math.random() * 800), 'token'); lftToken.body.gravity.y = 300; total++; } PLEASE HELP! The ultimate goal is to recreate this type of gameplay. One additional note: as of now I am dropping "tokens" using a random spawn loop. I'd rather use a timed patter for the token drop. If you have any advice on that please share as well. Thanks :]
  4. Hi all, I'm trying to use Slick UI to dynamically create multiple choice question prompts in a new game (see image). The problem is, there doesn't seem to be a way to remove a panel, or update its child elements once they have been created. I couldn't find a way to do this directly through Phaser either. Any help greatly appreciated. Perhaps there is a Phaser method to destroy all children generated by a particular plugin? Cheers, Paul.
  5. Hi everyone, I'm extending an sprite with the following code: Monster = function (game, x, y) {, game, x, y, 'monster01');, Phaser.Physics.ARCADE); //graphics this.anchor.set(.5, 1); this.body.setSize(290, 670, 330, 110); }; Monster.prototype = Object.create(Phaser.Sprite.prototype); Monster.prototype.constructor = Monster; Monster.prototype.update = function() { //input if( { if(Phaser.Rectangle.contains(this.body,, { BasicGame.PPGPlayer.clickOnMonster(this); } } }; I'm adding this sprite to the main state using: = new Monster(, * .5 + 400, 990); this.add.existing(; Then, I'm killing it with and the sprite disappears but the body is still on the state. If I render the body I can still see it: render: function (){; }, Why is this happening and what is the best way to solve it? Thanks!
  6. I have successfully applied the .kill() method to my bullets and enemies... the Problem is that it is registering 4 kills for each 1 enemy killed. I have been looking at this for hours and cannot figure out why it would be doing that. Any one have an idea as to why? phaserForumQuestion.js
  7. Killing wrong sprite in group?

    I have an enemy spawner which spawns enemies (duh) onto the playfield. I clone them using a group like so: this.enemy = this.enemies.getFirstDead(); this.enemy.reset(x, y); this.enemy.body.velocity.x = 200; When it collides with something, it kills the enemy. This works perfectly fine if there is one enemy, but once there are two enemies, I run into problems. When the first enemy collides with the hero, the SECOND enemy dies instead of the first. The second one spawned AFTER the first. How would I kill the first and not the second? KIll function: kill: function () { this.enemy.kill(); },
  8. Phaser Box2d Kill

    Hi, I'm doing a Gun that shots bullets. I put those bullets into a group and when a bullet touches something I kill the bullet. The problem is if I kill the bullet the sprite dissapears but it's body is still there. I can see it if I have game.debug.box2dWorld(); enabled. How can I remove it ? Is destroy() a better option? I'm reusing the bullet. Thank you
  9. How to kill object from group?

    Everytime player collides to any enemy, that enemy object needs to be killed. Enemies are made as group. I need some simple solution for this. this.enemies =; for (var i = 0; i < 90; i++) { this.enemy = this.enemies.create(x,y, i);; this.enemy.body.setMaterial(this.enemyMaterial); this.enemy.body.static = true; this.enemy.body.collideWorldBounds = true; this.enemy.outOfBoundsKill = true; this.enemy.body.velocity.x = 290 + Math.random() * 87; this.enemy.body.setCollisionGroup(this.enemyCG); this.enemy.body.collides([this.playerCG, this.wallsCG]); } this.player.body.collides(this.enemyCG, this.killEnemy, this); none of these does not work. How it works in the example then? killEnemy: function (player, enemy) { //'die'); // this.enemy.kill(); // this.enemy.destroy(); // this.enemies.remove(this.enemy); }
  10. I'm trying to remove sprites from a group using destroy() whenever the sprite goes out of the world bounds, but I'm getting an unexpected error: Cannot read property 'world' of null. Any idea why this is happening? function create() { buildings = var building = buildings.create(0, 0, 'building') building.body.velocity.y += 90, this)}function onBuildingOutOfBounds(building) { building.destroy() console.log(buildings.length)}
  11. Does Sprite Kill Remove Tweens

    Good morning! Quick question: I'm attaching tweens to sprites as a property ala: vSprite.myTween = this.add.tween(vSprite ,,, Do I need to explicitly remove the tweens before killing the sprite or will a sprite kill remove those tween references? Not sure if I need this: this.tweens.remove(vSprite.myTween) Thanks ya'll
  12. Do functions take parameters implicitly? I need to check for overlap and kill a sprite if overlap is true. So far, this is my code: update: function() { this.physics.arcade.collide(player,ground); this.physics.arcade.collide(letters,ground); this.physics.arcade.overlap(player, letters, this.collectLetter, null, this); this.physics.arcade.overlap(letters, ground, this.killLetter, null, this);My functions are: collectLetter: function(player,letter) { letter.kill(); //increase score }, killLetter: function(letter,ground) { letter.kill(); }But this doesn't seem to be working. The sprite is not being killed in killLetter, when it overlaps with the ground. Although it is being killed in collectLetter, i.e, when a player overlaps with it.
  13. destroy animation when finished

    I want to make an animation when you take a coin, and when the animation is complete, this animation is destroyed, not consuming resources. I've done that take the currency disappears, then appears the animation, but not destroyed after running animation ... I have the following code: var anim = game.add.sprite(coin.x, coin.y, 'coin'); anim .animations.add('walk'); anim'walk', 20, false);
  14. Hi guys, it is 27thColt here, back with another game. In my 2nd game, you are a guy on a bike trying to avoid and kill the robots in a fallen city. It is different than my first game and there are some things I was able to achieve which were hard before. Pics for some clicks: Github repository: Now the game might not look updated, so I can add any suggestions you guys have. Also, make sure to report bugs and ask questions.
  15. so i am making a platformer and i'd like to achieve mario like kill mechanics.. like if the player jumps on top of a say demon the demon dies but if the player touches the said demon from either side - right left or bottom, the player dies.... just like in mario if mario touches the moustache creatures mario dies or even if they fall on mario, mario dies but if he jumps or falls on top of them, they die.....