How to rotate the cars?


#1

I am trying to use a car animation and make it turn and go right. Every time I rotate it inside the edit animation 1/2 of the car disappears. How do I fix this? I can’t figure it out


#2

Hi Terri,

This is because the car animation is wider than it is tall, so when you rotate it, part of it goes off the canvas. You will need to first resize the canvas, making the car as tall as it is wide, then rotate it afterwards. Then, you can crop it back down if you want to.


#3

You can also use the rotation sprite property to rotate a sprite.

var sprite = createSprite(300, 200, 10,40);
function draw() {
//This will add 1 to the value each time the draw function is called. 
  sprite.rotation += 1 ;
//You can also just set it to a value. Like based on when a key has been pressed. 
if (keyDown("up")) {
      sprite.rotation = 90 ;
  }

  drawSprites();
}