Cocos2d-x game instances (14)-vertical version of the shooting game (1)

Source: Internet
Author: User

Small man (Bill man) Personal Original, welcome to reprint, reprint please indicate the address, small man (Bill man) column address http://blog.csdn.net/bill_man

Starting from this article, we will implement a simple vertical version of the shooting game. In this article, we will first build a simple example of leading aircraft movement. First, let's look at the implementation effect.

In this article, we will briefly implement an example of moving the main character in the stars, and use the previously introduced method of moving the main character to move the main character. First, add the following sentence to the scenario constructor: ccdirector: shareddirector ()-> setdeviceorientation (ccdeviceorientationportrait); converts the screen to a vertical screen.

Then let's look at the initialization function of the scenario:

First, define the protagonist, and then define the "star" behind the scenes. In order to make the plane have a running effect, we define two backgrounds for rolling.UpdateThe function provides this method of scrolling, and connects the two locations, and then implements some initialization content:Setistouchenabled (true); enable the scene to be touch-screen, scheduleupdate (); enable ourUpdateCan be executed, and then we set the index value-1

Check againUpdateFunction implementation:

It is to implement a simple map rolling. We reduce the coordinates of the two maps per frame.5If you think this speed is fast, you can adjust it. When a map is pushed out of the screen, place it below the map on the screen and let it continue to scroll.

Then, let's take a look at the implementation of the three touch screen functions that move the main character:

This is an example of moving the protagonist with his fingers. the difference here is that our protagonist is directly placed in the scene. Therefore, there is no relative coordinate problem and it is relatively simple.

If there are any errors, I hope you can correct them more.

Next article continues the vertical version of the shooting game instance

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.