Jump to content

Add player possibility 'squat'


Recommended Posts

I dont think i understood what you are asking. 

Do you want to reduce the height of the sprite? change it by sprite.height.


Do you want to make your character crouch? You must use a texture that shows him crouching, or an animation.



Add a crouch sprite to your character's spritesheet and adjust the sprite's bounding box with body.setSize(...) whenever the entity is crouching


Thanks guys.

I forgot about this topic.


But oxysoft's is right, I used setSize() method for reduce bounding box. Thanks.

Link to comment
Share on other sites

I'm not entirely sure, but I think your anchor point is going to determine where your sprite is scaled from/to.


If I just scale sprite - it will be ugly.


I need something such as http://jsfiddle.net/2e77q54s/19/ but without falling :)


I've just tried set scale:

- it's ugly

- after scale restoring hero falls under the ground layer

Edited by Chendler
Link to comment
Share on other sites

I found nice solution.

playerDuck: function() {            if (player.body.touching.down && !player._inDuck) {                player._verticalPosition = player.y;                player._normalHeight = player.height;                player._inDuck = true;                player.body.height = 0.75 * player._normalHeight;                player.y = player.y + player._normalHeight - player.body.height;                player.frame = 5;            }        },        playerUp: function() {            if (player.body.touching.down && player._inDuck) {                player._inDuck = false;                player.body.height = player._normalHeight;                player.y = player._verticalPosition;                player.frame = 2;            }        }

It works for me.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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