我绘制了许多彩色弧线,它们围绕着一个球旋转。当用户触摸屏幕时,球向其指针方向射击。 现在我想获得碰撞发生时碰撞的弧的颜色。 请帮忙.. 样本图像是这样的:
我希望以RGB格式或哈希格式输出或以任何已知格式输出,我可以将其用于比较。
请提出任何有用的建议......提前致谢..
答案 0 :(得分:2)
有没有理由不能简单地将每个弧视为一个单独的实例,并将颜色存储在一个字段中?
public class Arc
{
//color stored in the arc for easy retrieval
public Color myColor = new Color(...);
public void update()
{
//make the arc do everything the original arc was supposed to do
//such as rotate, get drawn to the screen, etc
}
//One of many ways to retrieve the color during a collision
public Color testCollision(Ball b)
{
if (/* Ball is colliding with arc */) return myColor;
else return null;
}
}