[英]Make a Bitmap “orbit” a point
I am trying to make a "wheel of buttons" - I have a custom "Button" object that uses a Rect for it's position/size. 我正在尝试制作“按钮之轮”-我有一个自定义的“按钮”对象,该对象使用Rect作为其位置/大小。
I can get one to rotate by doing this: 我可以这样做:
Button1.Rectangle.left = (int) (Vertex.x + (radius * Math.sin(Math.toRadians(Degree))));
Button1.Rectangle.top = (int) (Vertex.y + (radius * Math.cos(Math.toRadians(Degree))));
Button1.Rectangle.right = Button1.Rectangle.left + ButtonSize;
Button1.Rectangle.bottom = Button1.Rectangle.top + ButtonSize;
Degree += 1;
Unfortunately, this only works for one because they then all line up on eachother...how do I incorporate an "offset", or increment instead of assign the location 不幸的是,这仅适用于一个,因为它们然后全部彼此对齐...我如何合并“偏移”或增量而不是分配位置
I've tried: 我试过了:
//Using self position as vertex
Button1.Rectangle.left = (int) (Button1.Rectangle.left + (radius * Math.sin(Math.toRadians(Degree))));
Button1.Rectangle.top = (int) (Button1.Rectangle.top + (radius * Math.cos(Math.toRadians(Degree))));
and 和
// using +=
Button1.Rectangle.left += (int) (Vertex.x + (radius * Math.sin(Math.toRadians(Degree))));
Button1.Rectangle.top += (int) (Vertex.y + (radius * Math.cos(Math.toRadians(Degree))));
I know it must be something fairly easy, I'm just missing it... 我知道这一定很简单,我只是想念它...
EDIT: 编辑:
Fixed it by making a" 通过制作一个“
int Degree1 = 0;
int Degree2 = 90;
int Degree3 = 180;
etc.
and incrementing them: 并增加它们:
Degree1 += 1;
Degree2 += 1;
Degree3 += 1;
存储要旋转的原点,每次去计算它的位置时,都以原点而不是当前点为基准进行计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.