Santiago

Members
  • Content count

    22
  • Joined

  • Last visited

About Santiago

  • Rank
    Member

Profile Information

  • Gender
    Male
  • Location
    Argentina
  1. Group of enemies don't take damage

    That was the problem, I don't know how I've overlooked that, got to read better the API.- Thank you very much.-
  2. Group of enemies don't take damage

    Nobody can help?
  3. [Help] Sprite with solid color

    If I understand, you want to change the black background into transparent. In that case I'd use photoshop, is very easy to do it. I'd try first the background remover, setting the tolerance between 15-20% and 20 minutes (even less) of your time, you can clean all that black background.
  4. Group of enemies don't take damage

    Perfect, I realise now that I had this.enemies.createMultiple in exists = false (4th parameter), but if I set it to true, it avoids my addEnemies function and the MoveEnemies function and only appear one enemy flying. So, if exists is set to false everything's fine, but this.enemies.setAll('health',100); doesn't work, but if set to to true, works but I get a rare behavior, I'm uploading pictures to understand. Also, here is my code updated, I tried to simplify useless things. create: function () { this.cursor = game.input.keyboard.createCursorKeys(); this.jump = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.Q = game.input.keyboard.addKey(Phaser.Keyboard.Q); this.enter = game.input.keyboard.addKey(Phaser.Keyboard.ENTER); this.timer = 0; //ENEMIGOS this.enemies = game.add.group(); this.enemies.enableBody = true; this.enemies.setAll('body.immovable', true); this.enemies.setAll('anchor',0.5,1) this.enemies.createMultiple(10, 'enemigoAnim',[0,1,2,3,4]); this.enemies.setAll('health', 100); //ADD ENEMIES ANIMATIONS this.enemies.callAll('animations.add', 'animations', 'enemigoAnim', [0,1,2,3,4], 4, true); this.enemies.callAll('animations.play','animations','enemigoAnim') }, update: function () { game.physics.arcade.collide(this.player, this.walls); game.physics.arcade.collide(this.enemies, this.walls); game.physics.arcade.overlap(this.player, this.enemies); this.moveEnemies(); this.ataquePlayer() if (game.time.now > this.timer) { this.addEnemies(game.rnd.integerInRange(1)); this.timer = game.time.now + game.rnd.integerInRange(1000, 3000);; } }, addEnemies: function (){ var enemies = 5; for(var e = 0; e<enemies; e++){ var posX = game.world.randomX; if (posX > (this.player.x - 150) && posX < (this.player.x + 150)) posX = -80; this.enemy = this.enemies.getFirstDead(); if(!this.enemy) return; //PROPERTIES this.enemy.anchor.setTo(0.5, 1); this.enemy.reset(posX, 200) this.enemy.body.gravity.y = 1000; this.enemy.checkWorldBounds = true; this.enemy.outOfBoundsKill = true; } }, moveEnemies: function(){ for(var i = 0; i < 50; i++){ if(this.enemies.children[i].body.touching.down){ if(this.enemies.children[i].body.x < (this.player.body.x-40)) { this.enemies.children[i].body.velocity.x = 100; this.enemies.children[i].scale.x = 1; this.enemies.callAll('animations.play','animations','enemigoAnim') } else if(this.enemies.children[i].body.x > (this.player.body.x+40)){ this.enemies.children[i].body.velocity.x = -100; this.enemies.children[i].scale.x = -1; this.enemies.callAll('animations.play','animations','enemigoAnim') this.enemies.callAll('animations.play','animations','enemigoAnim') } else{ this.enemies.children[i].body.velocity.x = 0; this.enemies.callAll('animations.stop','animations','enemigoAnim') } } } }, } Beforehand thank you very much
  5. Group of enemies don't take damage

    I also could set my own health variable, not the phaser propertie and with a forEachAlive I killed the sprites, but kills all the group
  6. Group of enemies don't take damage

    That's what I thought! But can't set the health, I mean, I tried to this.enemies.health = 100, same with this.enemy of my addEnemies function. I can't change the health value of overlappingPlayer in this case, how could I do it? I don't know what else to do! I know I'm annoying but this cost me a lot to learn, I even re-write al the code 3 times with same results, I always end up in the same result!
  7. Group of enemies don't take damage

    Seems no one can help...
  8. Group of enemies don't take damage

    moveEnemies: function(){ for(var i = 0; i < 1; i++){ if(this.enemies.children[i].body.x < (this.player.body.x - 40)) { this.enemies.children[i].body.velocity.x = 100; } else if(this.enemies.children[i].body.x > (this.player.body.x + 40)){ this.enemies.children[i].body.velocity.x = -100; } } }, This is the function I use for moving my enemies. I don't think what you are saying is happening because in that case the health of enemies would be at a multiple of the damage taken, in this case 25 of 100, and the final health is -24, I still working on it and with no results
  9. Group of enemies don't take damage

    Could you explain better? I can't get what you mean.
  10. Group of enemies don't take damage

    Hey, that was really helpful! I appreciate it! Could you explain what you've done? Because as long as I'm still being a newbie, I can't understand at all how it works the function in the executing code of the if statement. Again I thank you very much, and the only problem came up is when overlappingEnemy.damage(25); is executed, enemies die instantly, because for some reason it takes 124 of damage, and I can't still to fix it.
  11. Group of enemies don't take damage

    I've forgotten something important, I got here an addEnemies() function, where I set the properties of the sprite, and I don't know if I should set the health property here, although I tried with negative results addEnemies: function (){ for(var e = 0; e<3; e++){ var posX = game.world.randomX; this.enemy = this.enemies.getFirstDead(); if(!this.enemy) return; //PROPERTIES this.enemy.anchor.setTo(0.5, 1); this.enemy.tint = 0x000000 this.enemy.reset(posX, 200) this.enemy.body.gravity.y = 500; this.enemy.checkWorldBounds = true; this.enemy.outOfBoundsKill = true; } },
  12. 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 = game.add.group(); 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.
  13. Hello, I got a simple game where a player moves and have a camera following it. Now, when I put a background and I want it to set it static while player moving, produce 2 things I don't want: the camera.follow(player) stop working and in the middle of the world the player stuck like a few seconds as a bug or something, and then continues. //Background ("fondo" is the background, if you don't know) this.fondo = game.add.image(0,0, 'fondoGame'); this.fondo.fixedToCamera = true; this.fondo.cameraOffset.setTo(0,0); this.fondo.scale.set(2); //PLAYER this.player = game.add.sprite(50, 100, 'vikingo'); this.player.anchor.setTo(0.5, 1); game.camera.follow(this.player); game.physics.arcade.enable(this.player); this.player.body.gravity.y = 800; I did a research but couldn't find something that could help me.