【问题标题】:Moving an object along a path ontouch在触摸时沿路径移动对象
【发布时间】:2019-11-13 22:37:55
【问题描述】:

我有一个描边圆路径和一个小填充圆路径,我想通过触摸沿着描边圆路径移动小圆,小圆不应该在描边圆之外。我怎样才能做到这一点 ?请帮帮我

【问题讨论】:

    标签: android path geometry


    【解决方案1】:

    您的触摸可能略微超出您的圈子路径。要提供圆上的对象位置,您可以进行以下操作:

        find position of touch against circle center
    dx = touch.x - center.x
    dy = touch.y - center.y
        find distance from the center
    dist = sqrt(dx*dx +dy*dy)
         make new position at the same disraction form center but at circle radius distance
    newx = center.x + radius * dx / dist
    newy = center.y + radius * dy / dist
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-02
      • 2011-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多