• Content count

  • Joined

  • Last visited

About Santiago

  • Rank
    Advanced Member

Profile Information

  • Gender
  • Location
  1. How to update an Arcade body?

  2. Like Samme said, using spritesheet every frame must be the same size, what you want to do requires an atlas.
  3. How to update an Arcade body?

    Hello, I'm doing a fighting videogame and I'm using Arcade Physics. since it's not possible to use multiple bodies with Arcade I'm trying to figure out how to update the bodies of my charecter (for complex positions I'll use more than 1 body to make it) once a key is down and when is up go back to the idle body. One of the possibilities I had in count and I tryied witout success is checking the current frame animation and adding some new invisible sprites like collliders and destroying it after the next frame. The first problem I had with it is that working on Update function it creates me a lot more extra sprites that waste resources, and had no success deletting it once the frame changes, I used this code: if ( == 'attack') { this.p = game.add.sprite(,, 'feet'); this.player.add(this.p); this.p.body.setSize(22,11,29,78); } if (this.p != undefined && != "ataque_1"){ this.p.destroy(); } The second possibility but I did not try is adding all the sprites I need to the player group and when I need it "activate" it with some property and check collisions with those invisible sprites, but I think will require a lot of resources that are no need it because there are a lot of animations and almost each animation needs +2 sprites for it, or if it can be another more efficent way to do this I don't know it yet. If anyone can help contributing another technique I could usem any idea or any help to do what I got in mind I'll be glad for it.
  4. How to "pre-debug" a non-existing object?

    Nobody can help?
  5. Hello, Title could sound weird, but idk very well how to express it. I'm working on a proyect that has an inicial player just with an arcade body, and I'm trying to add invisible sprites to adjust the movements with animations cause arcade allows just one body, and those sprites will be being added and destroyed constantly, so, for now I need to debug the body of those invisible sprites while programming, but I can't do it because those ones don't exist in the game at first, I tried some if clauses on render function but couldn't get it. create: function(){ this.vShape = new Phaser.Signal; this.vShape.add(this.shape); }, update: function(){ if (this.Q.isDown) {'attack'); } else {'idle'); } if ( == "attack_1") { this.vShape.dispatch(); } }, shape: function () { this.p = game.add.sprite(350, 89, 'attack1'); this.p.alpha = 0.1; this.p.rotation = -113.6; }, render: function () { game.debug.body(this.vikingo); game.debug.spriteBounds(this.p); } }; Last I tried was creating an undefined variable this.p in create funcion and checking in render function if it was undefined do nothing else if it wasn't (once replaced with shape) execute game.debug.spriteBounds(this.p); but didin't work, it was this way: create: function () { this.p; }, render: function () { if(this.p != undefined)game.debug.spriteBounds(this.p); } thanks for helping
  6. I'm trying to find some free alternative to Physics Editor to set polygons to my sprites for a game I'm trying to implement P2 physics, and for now I can't afford what it cost (even my proyect doesn't have commercial pruporses), and the 30 days trial is useless for me. I found a program called Physics body editor here: but the program is quite uncomfortable to use (doesn't matter, actually is unfinished) and polygons are very precise, using a lot of decimals, and I just need int values in the array. Does anyone knows any alternative?
  7. Can't play animations on group

    Nobody can help?
  8. Can't play animations on group

    I can't get on working some animations to a group of enemies, and I can't solve it. I could do it with a spritesheet, but with an atlas seems not working here's the code: moveEnemies: function () { for (var i = 0; i < this.enemies.length; i++) { this.enemyChild = this.enemies.children[i]; if (this.enemyChild.body.touching.down) { if (this.enemyChild.body.x < (this.player.body.x - 40)) { this.enemyChild.body.velocity.x = 100; this.enemyChild.scale.x = 1; this.enemies.callAll('animations.add', 'animations', 'enemigoAnim',Phaser.Animation.generateFrameNames('caminaE_', 1, 4), 10, true); this.enemies.callAll('', 'animations', 'caminaE_'); } else if (this.enemyChild.body.x > (this.player.body.x + 40)) { this.enemyChild.body.velocity.x = -100; this.enemyChild.scale.x = -1; this.enemies.callAll('animations.add', 'animations', 'enemigoAnim',Phaser.Animation.generateFrameNames('caminaE_', 1, 4), 10, true); this.enemies.callAll('', 'animations', 'caminaE_'); } else { this.enemies.children[i].body.velocity.x = 0; //this.enemies.callAll('animations.stop', 'animations', 'enemigoAnim') } } } }, ataquePlayer: function () { if (this.Q.justDown && game.physics.arcade.overlap(this.player, this.enemies)) { //'ataque') this.counter++ game.physics.arcade.overlap(this.player, this.enemies, function (player, enemy) { enemy.damage(25); enemy.body.drag.x = 150 if (player.scale.x == 1) { enemy.body.velocity.x = 130 enemy.body.velocity.y = -300 } else { enemy.body.velocity.x = -130 enemy.body.velocity.y = -300 } }); }
  9. Need help playing death animation

    If is useful for someone, I'm posting the solution I found:{ var death =,this.player.body.y,'vikingoAnim'); //Here I add my animation death.animations.add('death', Phaser.Animation.generateFrameNames('death_', 1, 10), 7, false); //I put the in the die variable die ='muerte'); //Kill animation when completes die.killOnComplete = true; }, this);
  10. Can't play animations

    I tried but seems to do nothing, it just stop for a moment the current animation (idle), but anything else, I don't know what else to do
  11. Need help playing death animation

    I've corrected my mistake in the last exists, but now it just disappear, and if I take out the if clause the behaviour is the same as recently, still there, existing. this.death= this.player.animations.add('death', Phaser.Animation.generateFrameNames('death_', 1, 10), 5, true);{ this.player.exists = true;'death'); if(this.death.onComplete){ this.player.exists = false; } }, this)
  12. Need help playing death animation

    I'm doing this: this.death= this.player.animations.add('death', Phaser.Animation.generateFrameNames('death_', 1, 10), 5, true);{ this.player.exists = true;'death'); if(this.death.onComplete){ this.player.exist = false; } }, this) Now the player still there, but the animation is not playing. I have corroborated that the animation is working, is there anything I'm doing wrong?
  13. Need help playing death animation

    Hello! I want to do a death animation but I can't get it, last thing I tried was using events, but I need some help here I was doing this on the create function:{'death')}, this); But it seems to do nothing, would be because the sprite is already killed? I am killing the sprite by damage() method. I don't know what else to do! And I can't find anything useful on Google Hope you can help me out!
  14. Can't play animations

    I set the loop parameter to false and still replaying it, using isDown propertie, but with justDown (what I need), doesn't play it at all, still playing the idle (I think I didin't say this, I forgot it)
  15. Can't play animations

    No one can help me out?