Sign in to follow this  
AlexArroyoDuque

[1.1.5] How I can change the size dynamically?

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
            }

Share this post


Link to post
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);
            }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.