python - kivy magnetic animation effect -


enter image description here

i trying teach students simple app. have made 2 apples draggable, can't figure out function have use make animating effect colored apples fit in same gray-colored apple.

here's code had made until now.

mn.py

from kivy.uix.widget import widget kivy.uix.behaviors import dragbehavior kivy.uix.image import image kivy.uix.scatter import scatter kivy.app import app 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.kv

<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' 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -