Jump to content

[1.1.5] How I can change the size dynamically?


AlexArroyoDuque
 Share

Recommended Posts

Hi! this is my code:

 

create:

            this.player = this.game.add.sprite(150, 150, 'player');
            this.player.anchor.setTo(0.5, 0.5);
            this.player.body.gravity.y = 650;
            this.player.scale.setTo(0.7, 0.7);
            this.player.body.bounce.y = 0.1;
            this.player.body.collideWorldBounds = true;
            this.player.body.setPolygon(40, 20, 80, 20, 100, 170, 30, 175);
            //If I don't put this, the player is generated in position 0, 0
            this.player.body.x = 150;
            this.player.body.y = 150;
 
update: 
 
          if (this.cursors.down.isDown && this.player.body.onFloor()) {
                console.log('down');
               //change size
            }
Link to comment
Share on other sites

If I put something to resize happens what I mentioned earlier ...

 

Hi!
I have a sprite scaled to a smaller size (0.5, 0.5). I want that when the player press the "down" the size change. What occurs to me is that changes the size but scaled back to (1, 1)
 
Greetings!

 

 

For example I could put something like this:

 if (this.cursors.down.isDown && this.player.body.onFloor()) {
                console.log('down');
               //change size
               this.player.body.setCircle(16);
            }

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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