Skip to content
Advertisement

How do I flip a sprite only on the x-axis with kaboom.js?

I want to flip my character to move left so that I dont have to animate a new left animation on every character (Yeah Im lazy). Is there an easy way to do this?

-Using kaboom.js

onKeyDown("a", () => { 
  player.move(-SPEED, 0), //moves sprite
  onKeyPress("a", () => { 
    player.play("RunSide"), //plays animation
    player.scale = -1, //trying to flip it here :)
    onKeyRelease("a", () => { 
      player.stop(), //stops animation
      player.frame = 0 
    }) 
  }) 
})

Advertisement

Answer

player.flipX(true) should work assuming that player is the sprite that you created

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement