如何解决旋转命令将rect转换为另一个位置处理
在处理中我将rect旋转了35。这是我的代码。
manage.py migrate
但是,如果我将旋转度更改为40,则rect旋转并平移到另一个位置。该如何解决?
解决方法
您的问题是,当您第一次使用rotate()
时,您是相对于整个画布旋转的,因此,当您使用canon1PositionX
,cannon1PositionY
时,取决于您当前所面对的角度画布位置变化。
您需要执行的操作如下:
pushMatrix();
// Go to the cannon position
translate(cannon1PositionX,cannon1PositionY);
// Rotate to the right angle
rotate(35);
// Draw the cannon at the current position and with the right angle
rect(0,25,60,50);
// Draw the second cannon next to the current one
rect(3,4,20,50,50);
popMatrix();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。