0
在我的iPhone上使用Pythonista 2,我試圖創建一個觸摸操縱桿。它是一個簡單的概念,我觸摸屏幕上的某個地方,操縱桿和邊界捕捉到該位置。然後,當我移動手指時,邊界保持不動,但內部的操縱桿移動,直到我到達邊界的邊緣,然後它沿着邊界中心和我的手指之間的圓的圓周。這裏是代碼:Python觸發問題
def touch_moved(self, touch):
global r
r = 90
l = (touch.location-c[0],touch.location-c[1])
a = math.degrees(math.tan(l[1]/l[0]))
if (touch.location[0] - c[0])**2 + (touch.location[1] - c[1])**2 < r**2:
self.joystick.position = touch.location
else:
self.joystick.position = ((math.cos(a)*r)+c[0],(math.sin(a)*r)+c[1])`
但是,遊戲杆外圍的溫暖,所以任何幫助表示讚賞。
非常感謝!它完美的工作! – BrrrIce