Jump to content

Physics not working


Recommended Posts

Hey guys so I have a sprite loaded by an atlas, I'm not able to make it move or applied physics to it, please see code bellow:

Can anyone tell me what did I do wrong? Basically all I get is the sprite and not moving in the edge of the screen.


//I load here:

  this.load.atlas('Monsters', 'images/monsters.png', 'images/monsters.json');

/////////timer to initiilize

 this.timerFiguras = this.time.events.loop(1000, this.makeFiguras, this);

/////////// below that 2 functions

 makeOneFigura: function() {
             this.figurai = this.game.add.sprite(0, 450, 'Monsters', this.rnd.integerInRange(0,4));
        this.figura = this.game.add.group();
        this.figura.enableBody = true;
          this.game.physics.p2.enable(this.figura, false);
        this.figura.setAll('anchor.x', 0.5);
        this.figura.setAll('anchor.y', 0.5);
        this.figura.setAll('outOfBoundsKill', true);
        this.figura.setAll('checkWorldBounds', true); 

      makeFiguras: function(){ 

         this.figuras = this.figura.getFirstExists(false);
        if (this.figuras) {
            this.figuras.reset(0, 450);
                    this.figuras.body.velocity.x = 1000;



Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...