Ammo – simple animation

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, ...

Get Kivy – Interactive Applications and Games in Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.