2016-02-29 74 views

回答

0

根据inclement的回答,我在分散布局上创建了一个按钮,它的点击框正确设置。

from kivy.app import App 
from kivy.lang import Builder 

kv = ''' 
FloatLayout: 

    ScatterLayout: 
     size_hint: None, None 
     size: 200, 200 
     pos_hint: {'center_x': .5, 'center_y': .5} 

     rotation: 45 

     do_rotation: False 
     do_scale: False 
     do_translation: False 

     Button: 
      text: 'hello world' 
''' 


class RotationApp(App): 
    def build(self): 
     return Builder.load_string(kv) 

RotationApp().run() 

我使用了散点图布局而不是散点图,因为它将其大小传递给子窗口小部件。在这个例子中不需要do_x: False,因为按钮拦截触摸事件,但如果我放置了标签,它将会移动。

3

您可能会重写其collide_point方法以通过转换触摸坐标来解释旋转。

如果您使用小工具系统(例如将Button放在Scatter中),碰撞就会为您照顾。