icecube110

Members
  • Content count

    6
  • Joined

  • Last visited

  1. I think the problem here is the beam's hitbox. You see, every sprite has a hitbox and it's basically a rectangle shape; rotating the beam at 45 degrees will not rotate the hitbox. You can change its size but not its shape; unless you take the p2 physics route which will have an impact on the performance due to the complex shape; it will require more cpu power. Granted I might be wrong about this and your problem might be something else...sorry that I can't give you a straight answer but I'm kinda new to Phaser myself. Someone more experienced might help you on this one Take a look here: https://phaser.io/examples/v2/p2-physics/body-debug Try to render the beam's body and see what's going on: update: function () { //stuff }, render: function () { this.game.debug.body(player); this.beams.forEachAlive(function (beams_body) { this.game.debug.body(beams_body); }, this); }
  2. @samid737 Ooohh yeah I get it, that makes sense now. Thanks for the explanation! It works great now, assigning a property did the job. Thank you both very much for your help!
  3. @samme I actually have more than 2 sprites in the group. (but only 2 enemies: red+blue) So what I mean is that I have a loop that creates multiple sprites (e.g. 20 blue enemies and 20 red enemies). They are 'separated' to say by 2 chars and 2 variables: 'b' for blue and 'r' for red + 'e_blue' (variable) / 'e_red' (variable). I also have a two-dimensional array that looks like this: system_var = [ 'bbb00000bbb', '000rrrrr000', 'bbb00000bbb', ]; Basically everytime it sees the letter 'b' it creates a blue enemy and adds it to the group / same goes to the char 'r' for the red enemy. (0 = empty) for (i = 0; i < system_var.length; i++) { for (j = 0; j < system_var.length; j++) { switch(system_var[j]){ case 'b': var e_blue = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_blue); break; case 'r': var e_red = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_red); break; } } } ------------ I thought that I could control these sprites by just using the variables I've provided them with. (e.g. there are 20 blue enemies that uses variable 'e_blue' and 20 red enemies that uses variable 'e_red') (so whenever I want all the blue enemies to move right I say e_blue.x++; and it moves all the 20 sprites I've created)... What is the correct way of doing this? Do I have to create a group for blue and one for red and then place them inside the 'mother' group (aka enemy_wave) ? Wouldn't that create a bigger 'mess'?
  4. Hello, I'm wondering if someone could help me solve this problem I have with 'Groups' in Phaser. So I have a group called 'enemy_wave' and it has 2 sprites attached to it: 'e_blue' and 'e_red'. Now, I want to 'kill' (sprite.kill();) 'e_blue' sprite and 'revive' (sprite.revive();) it later. Everytime I try to do that it also kills 'e_red', no matter how I put it. this.enemy_wave = game.add.group(); this.enemy_wave.enableBody = true; this.enemy_wave.physicsBodyType = Phaser.Physics.ARCADE; for (i = 0; i < system_var.length; i++) { for (j = 0; j < system_var[i].length; j++) { switch(system_var[i][j]){ case 'b': var e_blue = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_blue); break; case 'r': var e_red = this.enemy_wave.create(40 + 40 * j, 40 + 40 * i, 'enemies'); this.enemy_wave.add(e_red); break; } } } This is how I 'kill' sprites: this.enemy_wave.forEachAlive(function (e_blue) { e_blue.kill(); }, this); And this is how I 'revive' sprites: this.enemy_wave.forEachDead(function (e_blue) { e_blue.revive(); }, this); So yeah it doesn't matter if I kill 'e_blue' or 'e_red' because either way it 'kills'/'revives' all sprites attached to this group. How do I go about this? What seems wrong here? ~Thanks!
  5. Haha nice! Yeah that was it. I knew something was off but for some reason I couldn't get it. Thanks for the help!
  6. Hey guys, I have a quick question about 'Groups' as I'm kinda new to this Phaser HTML5 game dev. So my plan is to create multiple groups and have control over each one of them. First thing that came into my mind is to create a 'for loop' and be done with! Problem is that I don't know how to assign different names for a variable (wave).Example: Instead of doing this: this.wave00 = game.add.group(); this.wave00.enableBody = true; this.wave00.physicsBodyType = Phaser.Physics.ARCADE; this.wave01 = game.add.group(); this.wave01.enableBody = true; this.wave01.physicsBodyType = Phaser.Physics.ARCADE; this.wave02 = game.add.group(); this.wave02.enableBody = true; this.wave02.physicsBodyType = Phaser.Physics.ARCADE; I am trying to do this: for(i=0; i<10; i++){ this.['wave'+i] = game.add.group(); this.['wave'+i].enableBody = true; this.['wave'+i].physicsBodyType = Phaser.Physics.ARCADE; } So I'm sure you got the idea but this (['wave'+i]) is the problem. Can someone help me with this? What is the correct way of writing it? I've been searching but maybe I'm not questioning this correctly. Thanks and sorry for the noob question!