Book Image

Cocos2d-X Game Development Blueprints

By : Karan Sequeira
Book Image

Cocos2d-X Game Development Blueprints

By: Karan Sequeira

Overview of this book

Table of Contents (17 chapters)
Cocos2d-x Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Defining the fish


In Angry Fish, we have five different kinds of fish. Since they will share a lot of common behavior, we will define a base Fish class and inherit from Fish to specialize the behavior wherever required.

The following table describes each fish in brief:

Type of fish

Class

Description

Simple

Fish

The simplest kind of fish that can be launched from the catapult

Shooting

ShootingFish

Once launched, tapping the screen boosts this fish's velocity in the direction of motion

Splitting

SplittingFish

Once launched, tapping the screen causes this fish to split into multiple smaller fish

Bombing

BombingFish

Once launched, tapping the screen causes this fish to hurl a smaller fish downwards

Exploding

ExplodingFish

Once launched, this fish automatically explodes after landing or hitting something

The Fish class

We now define the base class for the fish. The Fish class will inherit from parent class GameObject, which is identical to the one you've seen...