奇维磁性动画

2024-04-19 23:19:22 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here

我试着用一个简单的应用程序来教学生。 我已经做了两个苹果拖拽,但不知道我必须使用哪个功能,使动画效果,彩色苹果适合同一个灰色的苹果。你知道吗

这是我的代码,我一直到现在。你知道吗

锰系

from kivy.uix.widget import Widget
from kivy.uix.behaviors import DragBehavior
from kivy.uix.image import Image
from kivy.uix.scatter import Scatter
from kivy.app import App
from kivy.properties import StringProperty


class apple_0(DragBehavior,Widget):
    def on_touch_move(self,touch):
        return super(apple_0, self).on_touch_move(touch)

class apple_1(DragBehavior,Widget):
    def on_touch_move(self,touch):
        return super(apple_1, self).on_touch_move(touch)


class base_0(Image):
    def basepicture_0(self):
        pass

class mn(Widget):
    pass

class mnApp(App):
    def build(self):
        return mn()

if __name__=='__main__':
    mnApp().run()

毫伏

<mn>:
    canvas:
        Color:
            rgb: 1,1,1,1
        Rectangle:
            size: root.width,root.height
            pos: 0,0

    Label:
        pos: 30, root.top- 70
        text:
            ('[size=20][color=000000]'
            'fnc_slide_0'
            '[/color][/0ize]')
        markup: True

    apple_0:
        id: apple_0_id
        pos: root.width/3,root.height/8
        auto_bring_to_front: True

    apple_1:
        id: apple_1_id
        pos: root.width/5,root.height/8
        auto_bring_to_front: True

    base_0:
        id: base_0_id
        pos: root.width/7, root.height/3


<apple_0>:
    size: 75,75
    drag_rectangle: self.x, self.y, self.width, self.height
    drag_timeout: 10000000
    drag_distance: 0
    canvas:
        Rectangle:
            pos: self.pos
            size: self.size
            source: 'apple_0.png'

<apple_1>:
    size: 75,75
    drag_rectangle: self.x, self.y, self.width, self.height
    drag_timeout: 10000000
    drag_distance: 0
    canvas:
        Rectangle:
            pos: self.pos
            size: self.size
            source: 'apple_1.png'

<base_0>
    size: 944, 502
    canvas:
        Rectangle:
            pos: self.pos
            size: self.size
            source: 'base_0.png'

Tags: fromposimportselfidapplebasesize