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