iOS game source download simple version of Thunder (2.2.3 version) source full download and simple development tutorial

Source: Internet
Author: User



Head back to write tutorial this thing, really do not know what to write, so the main is to share my code, and some important features of the explanation, if you do not understand what you can reply to questions yo.

In fact, this demo (why called demo, because I really dare not call this for the game) is my beginner cocos2d-x two weeks when written, so may not write very well (well, in fact, now write things are not good), the original mainly by degrees Niang and Testcpp learned, So here is still to emphasize the importance of testcpp, to take a good look at Yo, after you want to realize what function you can go to look over.


Well, to get to the point, or introduce me to write this demo, in this first gorgeous Li presents a few to raise the eye-pleasing.



next talk about the function of this demo, three levels, each level a different boss and three kinds of the same creeps, creeps different levels of bullets, the mobile path is dead (why should be dead, because the original young naïve I want to like thunder and lightning to control the number and path of each wave of enemy species, The result you understand, I failed, can not write Ah have wood, it became this. Five props, missiles (full-screen seconds to kill), gems (red plus bullets, blue plus shield, purple Health, gems change color every time), gold coins (increase score, every 100 points plus 1 life). OK, I know what you want to know is how to write, then I will not wordy, first to look at all the header files.

Loadlogono use, is running the game when the first show a picture, many games is to display a bunch of logo
Ccradiomenuis a multi-select button control, found on the Web, select the level with
gameeventused to manage different scenes to toggle playback of what effect, define the current game level this global variable
Gamelevelis to choose the level interface.
Gamemenugame menu, start, exit game
Gamemapgame background, display different pictures according to different levels
GamemessageThe game information is the top of the show HP, scores, life what
GameoverGame Failure Interface
EffectCreate a cache of coins and exploded animations, and create animations later without having to recreate
Movetrackarraymove the track class, because my trajectory is dead.
Unitspriteunit classes, props, bullets, and aircraft properties
BulletspriteBullets, Inheritance unit class, Bullet logic
Itemspriteprops class, Inherit unit class, prop logic
Rolespritecharacter classes, inheriting unit classes, mainly what the player and the enemy have in common (flight animations are hit and explode, etc.)
Playerspriteplayer class, inheriting role class, player's logic
EnemyspriteEnemy class, inheriting the role class, the enemy's logic
Bossspriteenemy boss class, inherit the enemy class, the enemy boss logic
Gamemangergame Management class to create the objects required for all games
Bulletmanagerbullet Management class, create and delete all bullets
Enemymanagerenemy Management class, create and delete all enemies
ItemmanagerProps Management class, create and delete all props
first of all, the effect of the menu, Meteor drop Needless to say is ccparticlesun particle effect, open a timer schedule, let it always from the upper left corner of a random place to perform the move. Stara star blink is a ccfadeout gradient transparent action and its reverse (the inverse of the animation), which is permanently played through the Ccsequence sequence action and Ccrepeatforever.

Next talk about choosing the level interface, the middle of that feature is also a particle effect, ccparticlesystemquad, in the testcpp look at a good to take over. The selection effect of the level is also Ccparticlesun, set the next startsize, that's what it looks like. You might ask me why I don't set a multiplier directly, you can try it, and then you'll be amazed to find out that the vanishing point will be offset, and why, I don't know.

and then what to say, the circle of the enemy bullets spread moving trajectory, it is very simple, is based on a circular polar equation (x = rcos (θ), y = rsin (θ)) according to the radius and the interval angle of two bullets, constantly increasing the radius. Suppose three bullets, bullets spaced 20 degrees, three bullets θ were 250 degrees, 270 degrees, 290 degrees, because 270 degrees is just below.

The enemy's movement trajectory, is the ccpointarray to save the moving point, and then through the Cccardinalsplineby to move, detailed use can see testcpp.


Collision check, are in props class Ah bullets ah enemy class AH inside open an update, through the BoundingBox to detect collisions with other objects. This involves different objects.
The interaction of the data, I was in the Gamemanager the class that is going to interact with the data is set to static, and then the object address is obtained through the function.

Switch to the next level, you will be surprised to find that I was in the Gamemanager to delete a bunch of objects to re-create, because I originally used Replacescene to switch their scenes, will lead to the data also cleared, so it did so. At that time, I was young and ignorant, do not know to create a single case of data management class to save the data ah.


The random movement of props, is to open a timer, set a mobile point to move, and then always change the moving point
.

Perhaps you have found that my objects are deleted in the update of their management class, you may be thinking about what I use to write, in fact, I did not know removefromparent Ah, do not know ccremoveself ah. Also why my blood bar to use settexturerect, because I do not know Ccprogresstimer Ah!

The use of the missile's shock screen effect, is actually used ccjumpby only, look at the effect is good.

Also, to say about the object's property setting is to pass a type variable, and then use the switch case to determine the value of the type to set different property values.

If you want to ask why these class names are named Xxxsprite but inherit Cclayer instead of inheriting ccsprite, the reason is that I didn't register the touch event with Ccsprite, so I started the touch directly with Cclayer.

Do not know what to write, not good at writing tutorials Ah hello, or relatively good at answering questions, in fact, this demo is not much difficult, you can go to take a good look at the code, there are questions can reply to questions, I will answer.

Code Download: Simple version Lightning http://www.cgzhw.com/?p=3501

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.