June 2015
Intermediate to advanced
206 pages
4h 32m
English
This section explains how to animate shots and missiles, which show very similar behavior. They move from their original position to a destination, constantly checking whether a target has been hit. The following is the code for the ammo.py class:
61. # File name: ammo.py 62. from kivy.animation import Animation 63. from kivy.uix.image import Image 64. from boom import Boom 65. 66. class Ammo(Image): 67. def shoot(self, tx, ty, target): 68. self.target = target 69. self.animation = Animation(x=tx, top=ty) 70. self.animation.bind(on_start = self.on_start) 71. self.animation.bind(on_progress = self.on_progress) 72. self.animation.bind(on_complete = self.on_stop) 73. self.animation.start(self) 74. 75. def on_start(self, instance, ...
Read now
Unlock full access