Cocos2d-x 3.0 game instance learning notes "parkour" End-source code release

Source: Internet
Author: User

(Here is the reference: Xiaofeng residual month predecessors blog, he is the teiran network parkour tutorial, with the cocos2d-x 2.x version number to rewrite, now I am learning cocos2d-X3.0 so I will use cocos2d-X 3.0 rewrite, take notes

OK. We have basically finished writing the game until yesterday. This is something that was originally open source for others. I will rewrite it here, and of course we will release the source code. There are two methods:

First: Package the entire project that has been successfully executed by me. This method is larger than that of supervisor under vs2012 + win7, but it can be opened to run/proj. win32/run. SLN is enough.

Another is that I only package the resources and class .. However, there will be extension problems, because I used the button, this solution in front of the cocos2d-x 3.0 game instance learning notes "parkour" Step 5 -- button control protagonist jump & crouch which has a specific solution

Or leave a mailbox

Bug fixed and shared changed ----- 2014-8-2

Link:Entire Project204 M ----------Resource & code1.18 m

Note: Do we need to add the crouchevent function in playscene? Assume that m_runner-> getstate () = running is used to run m_runner-> crouch (); m_runner-> setposition (.......); otherwise, in the case of jumping up, buttoncrouch, although the main character will not crouch, it will change the position of setposition .......

I just had another small problem yesterday. I wanted to solve it yesterday and I will give it here. Who knows .... Alas .. The problem is:

In our game, the main character hits the rock and switches to the gameover scene, which has a button and restart. Again, the following callback function switches to a game scenario... However, the button will become invalid .... However, this is not a question about Button writing. In appdelegate, we use the gameover scenario, and then the button can be switched to the game scenario .. After the game is switched to mainscene, startbutton becomes invalid again... I have also asked many people here, but I have not solved the problem because my personal description is unclear. I hope you can find a solution for downloading the source code and share it with me and everyone...

Hahaha, it's a long time. The bug is solved. Is it actually added to the collision detection? An error occurred while distributing the event:

Incorrect code changes:

<Span style = "font-size: 14px;"> void playscene: onenter () {layer: onenter (); Auto contactlistenner = eventlistenerphysicscontact: Create (); // cc_callback indicates the number of workers in the callback function contactlistenner-> oncontactbegin = cc_callback_1 (playscene: oncontactbegin, this); // dispatcher = Director: getinstance () -> geteventdispatcher (); // you will not use your own event distribution here. // _ eventdispatcher should be a global variable for time distribution .. All the _ eventdispatcher-> addeventlistenerwithscenegraphpriority (contactlistenner, this) managed for it;} </span>

The new complete project has been packaged, and all of the above are updated... so that we can finally get the next game instance at ease.


Conclusion: in fact, the most effective way for a person to learn is to learn the knowledge point, use the instance to practice, and practice it in the instance. We should first understand the design idea, and then try to implement it first. There may be many problems in the process. You can view the source code and separate some functions into an example, or Baidu .... Instead of asking questions everywhere, in the words of one of our teachers: Learning to Learn to learn will benefit you for the rest of your life.

OK, personal ignorance. You are welcome to correct and discuss it.

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.