-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (28 loc) · 884 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.properties import ObjectProperty
from kivy.clock import Clock
class AnimatingImage(Image):
time = 0.0
rate = 0.2
frame = 1
def update(self, dt):
self.time += dt
if (self.time > self.rate):
self.time -= self.rate
self.source = "atlas://invader/frame" + str(self.frame)
self.frame = self.frame + 1
if (self.frame > 2):
self.frame = 1
class AnimationScreen(Widget):
invader = ObjectProperty(None)
def update(self, dt):
self.invader.update(dt)
class AnimationApp(App):
def build(self):
animation = AnimationScreen()
Clock.schedule_interval(animation.update, 1.0/60.0)
return animation
if __name__ == '__main__':
AnimationApp().run()