Cocos2d-x 3.1.1 Learning Log 5-Implementation of cocos2d-x3.1.1 aircraft hitting, cocos2d3.1.1

Source: Internet
Author: User

Cocos2d-x 3.1.1 Learning Log 5-Implementation of cocos2d-x3.1.1 aircraft hitting, cocos2d3.1.1

I recently learned some features of cocos2dx3.1.1 and thought there were too many changes with previous versions. So I made a small project-aircraft to practice, here I only talk about the implementation of the steps, as for the code, reply 5 times to get the Source Code address of the coco2d-x3.1.1 download. (If not, leave a mailbox. I will send it to you in person !!)

(1) Let's work out the entire project framework and logic step by step. The following describes how to enter the game interface by writing a start interface.

(2) We initialized some data, Genie, and set the rolling background. Of course, we need to implement it step by step. We have to figure out the logic. This function is implemented, and then what to implement next, and then wait until it is completed ....

(3) Let's move our plane following our fingers. Simply, we can use the layer touch event to set setTouchEnabled to true,

(4) We have added the bullet launching function because the bullets are automatically fired and do not need to be fired through the button. Therefore, at this time, you can create only one bullet genie.

(5) We create a bullet, set the speed of the bullet, and open the fire. When the screen is exceeded, we reset the position of the bullet.

(6) An airplane can be moved and bullets can be fired. Now, we need to join the enemy plane.

(7) then we need to make this enemy plane, which has various types (large, neutral, and small ).

(8) Next, we need to consider collision detection. My plane bullets hit the enemy's plane and show the corresponding scores. Here, we need to know what it is and what it is. Here it is very simple: the bullets of the plane have a collision with the enemy's plane, and the enemy's plane has a collision with my plane.

(9) we have defined a collision detection function collisionDetection. We can use the intersectsRect function to determine whether the bullet's rectangular area is in the rectangular area of the enemy plane, when the amount of blood is less than or equal to 0, it will trigger the explosion of our aircraft, remove the plane that died, set the score to display, otherwise there will be a hit animation during the blow.

(10) complete the remaining functions. First, we add the function of changing bullets or bombs. The principle is generally as follows: set the time interval when an item appears, the type of the item is displayed randomly, and then the item and the plane are located in the same area for collision detection. Even if you get the item together, you are OK.

(11) We define an item change class, set its item categories, more powerful bullets and bombs, and construct an item animation function. This animation function is very simple, are made up of CCMove.



Don't understand can add my QQ group: 239982941 (cocos2d-x 3.1.1 Learning Group)


Cocos2d-x is how to realize the game, I am an artist so want to understand the art of the process to do what step? What tools are used to provide resources for cocos2d-x

I think we should plot a png Image and package many images into plist files.
Read with animation, there are examples in testcpp in the cocos2d-x (animation Operation)

Game Development novice teach Cocos2D-X how to learn, only C ++ development experience

Congratulations, cocos2d-x is written in c ++, theory can refer to the relevant cocos2d. There are many cocos2d communities on the Internet. Let's take a look! Visit more forums. We need to understand scenarios, layers, Genie, actions, and other related concepts.

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.