在画布中旋转图像

时间:2019-03-05 05:19:02

标签: javascript canvas graphics2d

我已经盯着这个代码两个小时了,我不知道为什么它渲染不正确,应该只旋转图像,但它会飞过整个屏幕,画布设置为屏幕的宽度和高度。

 const gr = document.getElementById('maingame').getContext("2d")
 
 gr.translate(camx + window.innerWidth / 2, camy + window.innerHeight / 2)//moves the camera
//draws other players
    gr.save()
    gr.translate(-camx-players[i].x,-camy-players[i].y)
    gr.rotate(players[i].d)
    gr.drawImage(main0,players[i].x -(main0.width * size) / 2,players[i].y -(main0.width * size) / 2,main0.width * size, main0.height * size)
    gr.restore()

0 个答案:

没有答案
相关问题