Jump to content

Search the Community

Showing results for tags 'foreach'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 7 results

  1. Hi, I don't know how to assign the life variable individually to each zombie, avoiding that when one is hit, life is taken away from everyone. Same thing for the infectStatus which affects all zombies and not the individual. Thanks a lot! var zombies; var zombieLife = 3 this.create = () => { zombies = game.add.group(); zombies.enableBody = true; zombies.physicsBodyType = Phaser.Physics.ARCADE; var zombie0 = game.add.sprite(500, 1400, 'zombie'); var zombie1 = game.add.sprite(600, 1400, 'zombie'); zombies.add(zombie0); zombies.add(zombie1); zombies.setAll('anchor.x
  2. I have an array of items (stored as strings) I am displaying on screen as sprites, in an inventory. I want to update my array when an item is removed from my inventory, so I want to write a function that resets the x position of the objects. I can log out the right object and the right index value, but I can't seem to set the position of the object using this function. Any ideas ? example: inventory('key', 'rock', 'sword', 'note'); resetSlots: function() { //for every item in inventory, slot position is index number. inventory.forEach(function(item, index){ i
  3. Hi , I m new user of phaser and i develop a retro shoot them up for the GameOFF jam . i have a problem in my game state : enemyTween: function(){ this.enemyPool.forEachAlive(function(enemy){ enemyTween = this.game.add.tween(enemy) }) TypeError: this.game is undefined [En savoir plus] why i cant acces to game and other event into function of group? (sorry for my bad english)
  4. So in my game the player object is made up of several different sprites, so I made a Group called "player," and tried to add an object to it, "rover_proto." I am also trying to use forEach() to change attributes of each item belonging to the group. Here is my code: function createGameScene() { // format: (game, name, addToStage, enableBody, physicsBodyType) player = game.add.group(game.world, 'player', true, true, Phaser.Physics.P2); Rover_proto = player.create(0, 0, 'Rover_proto'); //player.setAll('body', true, true, false); //Group collision player.forEachExists(functio
  5. Hi, I have this code: console.log("top dead: " + this.topGrp.countDead()); // 3 this.topGrp.forEachDead((child) => { console.log("destroy top"); // only 2 times in chrome's console child.destroy(); }, this); topGrp is a group the function countDead() returns 3, and then forEachDead is iterating only 2 time, I see this in the console and only 2 object in my game are destroyed... help?? thanks! Lior
  6. Hello there. Im new to phaser so im trying to learn it, but in the process i have came across a few troubles with groups and forEach method. Here is what i have: starGroup.forEach(function(eachStar) { if (gameBegun==true && planeSprite.body.hitTest(eachStar.x+8, eachStar.y+30) && eachStar.frame<=30) { eachStar.animations.play('taken', 24, false, true); } if(eachStar.frame>50)// this line here doesnt work for some reason { alert('easf'); }});So if you notice that if(eachStar.frame>50), it doesnt work, for some str
  7. Hi guys, I use the following (shortened) code: updateGroups() { console.log(this.tiles); this.tiles.forEach(function(tileGroup) { var tile = tileGroup.getAt(0); var value = tile.val; var valueText = tileGroup.getAt(1); if (value == 0) { this.emptyTiles.add(tileGroup); } else { this.occupiedTiles.add(tileGroup); } }, this); }As I made sure (with logging it to the console) the group "tiles" has ch
×
×
  • Create New...