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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.