-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Building Games with Flutter
By :

In this section, we will start by connecting George's movement to the joystick.
Currently, the George
class inherits his movement from the base class, Character
, which it shares with the Skeleton
and Zombie
classes. As George will have different movement code from the enemy sprites, let's refactor the code to allow the enemy sprites' movement code. We will move the existing movement code into an EnemyCharacter
class, which will become the new base class for the enemy sprites and remove this code from the Character
class.
Let's get started:
components
folder, create a file called character_enemy.dart
.In this code, the EnemyCharacter
class extends our Character
class, and we have copied the onCollision
, update
, and changeDirection
functions...