Cocos2dx anti-tower game logic1. Welcome Page
2. Create a game map using tield. Set the cantouch attribute to 1 for empty blocks.
3. Set the map anchor, add the anchor to an anchor container, and pass the anchor's walking function to the anchor container parameters to let the monster walk by the anchor.
4. create a turret (touch coordinates to map, convert turret array coordinates) first check whether a turret can be created at the touch start position, and then create the turret selection interface, the position is the entire part. Then, based on the touch, select the part on which the turret is to be created.
5. Collision Detection: add the dead enemy to the dead enemy container, traverse and remove the conflicted bullets, and traverse and remove the bullets.
6.
Turret base class (Turret divided into three categories, rotation shooting, shooting, multi-direction shooting) base class sets the turret line of sight range, lethal detection nearlyenemy, the nearest enemy
Enemy base (3 types of enemies): Set enemy attributes, walking speed, blood volume, current blood volume, set basic enemy movements, turn left, and turn right animation, explosion animation, set enemy direction judgment function, set enemy anchor container
Enemy class thief1. initialize the right turn animation, add the left turn animation to the animation cache, and initialize the monster Animation 2. create a function. 3. create an enemy function (input the anchor container, HP) 4. enemy direction changing judgment function (called per frame) 5. explosion Animation
Tower attacktower1. initialize sight, Tag, lethal effect, Image 2. Add turret Bullet 3. Add shooting function 4. Remove bullet function
Cocos2dx anti-tower game logic