+ 5
How can i stop other elements from rotating on canvas ?
So in the following code when bird Hits rectangle ,fall_down function in Bird class is called where it is being rotated ,but it also rotates rectangle,so how can I just rotate bird? https://code.sololearn.com/WcBQHr95syMW/?ref=app
2 Antworten
+ 4
into class Bird, you can put it in a function called render:
///////////
render(ctx){
ctx.save();
ctx.translate(this.pos.x, this.pos.y);
ctx.rotate(-degToRad(this.rotationDegs));
ctx.drawImage(this.sprite, 0, 0, this.width, this.height);
ctx.restore();
}
//////////
function degToRad(degs) {
return (Math.PI / 180) * degs;
}
+ 3
luis calderón thanks a lot