我试图旋转小部件,然后使用collide_point方法检查我是否触摸了小部件
问题是,当我旋转小部件时,画布(图像)可以正常工作,但小部件本身似乎没有旋转,因此检查失败
.py:
SELECT p.*
FROM (SELECT p.*,
ROW_NUMBER() OVER (PARTITION BY product_category,
product_id IN (3178, 3181, 7403)
ORDER BY product_category
) as seqnum
FROM products p
WHERE product_category IN (12, 36) OR
product_id IN (3178, 3181, 7403)
) p
WHERE seqnum <= 3
ORDER BY (product_category = 12) DESC,
(product_category = 36) DESC;
.kv:
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.widget import Widget
class Game(Widget):
pass
def on_touch_down(self, touch):
if self.player.collide_point(*touch.pos):
print("collide")
class TestApp(App):
def build(self):
Window.size = 300, 300
self.game = Game()
return self.game
if __name__ == "__main__":
TestApp().run()
我希望在触摸图像时会发生打印碰撞,但只有在触摸旋转前的图像时才发生打印碰撞
编辑:
我必须这样做吗? (它有效,但是没有简单的方法吗?)
<Game>:
player: player
Widget:
id: player
angle: 50
size: 40, 200
canvas:
Color:
rgba: 1,0.5,0,1
Rectangle:
pos: self.pos
size: self.size
canvas.before:
PushMatrix
Rotate:
axis: 0, 0, 1
angle: self.angle
origin: self.right, self.top
canvas.after:
PopMatrix