Because the course is required. And then the level is limited. So I wrote a plane war. Plus you can't draw. So the picture resources are extracted from the APK, design ideas for the occasional e-network.
Gossip doesn't say. Let's talk about the design first. In general, it is divided into 3 scenarios. The scene below is the layer
Start scene: Welcomescene-->welcomelayer Similar Welcome interface
Game main scene: Gamescene---Gamelayer game element join and Collision detection
End scene: Gameoverscene-->gameoverlayer
Then there are the elements of the game, added in Gamelayer, a layer divided into 4 layers:
Planelayer: main character layer
Enemylayer: Enemy plane, divided into 3 kinds, each enemy aircraft life value is not the same
Ufolayer: Prop layer, bullet and add bomb
Bulletlayer: Bullet layer Bullet and Mutibullet
Then simply talk about the implementation of the collision detection:
if (Bullet->boundingbox (). Intersectsrect (Enemy1->getboundingbox ())) {if (enemy1->getlife () = = 1) {enemy1- >loselife (); Bulletstodelete->addobject (bullet); Enemy1todelete->addobject (enemy1); score + = Enemy1_score; This->mcontrollayer->updatescore (score);}}
Rect Enemy::getboundingbox () {Rect rect = This->m_sprite->boundingbox (); Point pos = This->converttoworldspace (rect.origin); return rect (Pos.x, Pos.y, Rect.size.width, rect.size.height);}
And then there's the bullet layer processing:
Bullet launch Required steps: 1. Add bullets, 2. Move bullets. 3 Removing bullets
Because of the need to continuously launch bullets, so the bullets into a spritebatchnode node. Then the bullet is added, moved, and removed at this spritebatchnode node, and the advantage is that it only needs to be rendered once. Reduce memory consumption
Auto texture = texturecache::getinstance ()->textureforkey ("Shoot.png"); Bulletbatchnode = Spritebatchnode:: Createwithtexture (texture); This->addchild (Bulletbatchnode);
And then we'll talk about a resource handling:
Download this tool: Plist parsing tool
Resolve the required resources. Then you can work with Photoshop, haha. Be able to get rid of the pictures, whatever p on their own name
Then pack it with Texturepacker. Well. It's probably like this.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2h1bl9memxs/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
Finally, let's talk about the steps and details compiled into Androidproject:
1. First add all necessary CPP to the Android.mk file
2. Remember to add resolution adaptation to the Appdelegate CPP
Glview->setdesignresolutionsize (480,800,resolutionpolicy::show_all);
3. In the Proj.android directory, the following changes androidmanifest.xml the vertical screen properties:
android:screenorientation= "Portrait"
4.cmd to the project folder. Command:Cocos compile-p android-j 4
Source code: Aircraft War
COCOS2DX 3.0 Aircraft War