+ 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

8th Aug 2020, 11:49 PM
Abhay
Abhay - avatar
2 Réponses
+ 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; }
9th Aug 2020, 1:36 AM
CoffeeByte
CoffeeByte - avatar
+ 3
luis calderón thanks a lot
9th Aug 2020, 9:06 AM
Abhay
Abhay - avatar