The source code for iOS game "Rift Warrior" (Yes, I'm the developer and product owner)
The original game can be downloaded from the link: Rift Warrior at AppStore.
Preview GamePlay Video on Youtube
Preview Game Introduction Video on Tudou(For China)
All account specific logic&data have been removed, such as In-App-Purchase, Google Ads, Social Network Sharing, and Flurry tracking. All others remain the same.
Use the latest Xcode (tested with Xcode 9) and open: code/projects/riftwarrior/proj.ios/riftwarrior.xcodeproj
- The game map was created/modified using Tiled Map Editor -- I'm not sure if the latest tiled map editor is supported by cocos2d-x 2.2.6. If not, try find the editor released in 2014
- The opening scene anaimation was done by Cocos Builder link
- The original game data (configurations) was encrypted using sqlcipher. Now it's just a simple sqlite db located at code/projects/riftwarrior/Resources/db/game.db
Game entry point: AppDelegate.cpp -> startGame()
GameScene: Base Layer containing MainUI, WorldMap and GameStage.
GameStage: Kind of a "ShowStage" to place map, tower(building), and actors(enemy/player). This is similar to the "stage" concept in Flash game.
StageMap: Handling all map related data
One the core issues in tower defense (or RTS) game design is how to construct code to handle different attacking weapons with various attack styles. The answer is to use component based pattern.
Taking "Building.h" for example. Building is kind of a container which contains different weapon. In the code, each "building" contains a "AttackComponent", and we inherit "AttackComponent" to implement different concrete attack weapons. The building itself doesn't care how the weapon attacks.
Same applies for Player.h
In our later game "Rise of the Orcs", we further moved to have MoveComponent, AttackComponent and AIComponent to implement more complicated logic in various aspects. For this tower defense game, it's roughly good enough to handle.