diff --git a/doc/concepts.html b/doc/concepts.html index 2517f0e..270383a 100644 --- a/doc/concepts.html +++ b/doc/concepts.html @@ -7,13 +7,13 @@

Cocos2d Basic Concepts

A regular hierarchy chart may look like this:

Alt text

Scenes

-

A scene (implemented with the CCScene object) is more or less an independent piece of the app workflow. Some people may call them ¡°screens¡± or ¡°stages¡±. Your app can have many scenes, but only one of them is active at a given time.

+

A scene (implemented with the CCScene object) is more or less an independent piece of the app workflow. Some people may call them "screens" or "stages". Your app can have many scenes, but only one of them is active at a given time.

A cocos2d CCScene is composed of one or more layers (implemented with the CCLayer object), all of them piled up. Layers give the scene an appearance and behavior; the normal use case is to just make instances of Scene with the layers that you want.

There is also a family of CCScene classes called transitions (implemented with the CCTransitionScene object) which allow you to make transitions between two scenes (fade out/in, slide from a side, etc).

Since scenes are subclasses of CCNode, they can be transformed manually or by using actions. See Actions for more detail about actions.

Director

The CCDirector is the component which takes care of going back and forth between scenes.

-

The CCDirector is a shared (singleton) object. It knows which scene is currently active, and it handles a stack of scenes to allow things like ¡°scene calls¡± (pausing a Scene and putting it on hold while another enters, and then returning to the original). The CCDirector is the one who will actually change the CCScene, after a CCLayer has asked for push, replacement or end of the current scene.

+

The CCDirector is a shared (singleton) object. It knows which scene is currently active, and it handles a stack of scenes to allow things like "scene calls" (pausing a Scene and putting it on hold while another enters, and then returning to the original). The CCDirector is the one who will actually change the CCScene, after a CCLayer has asked for push, replacement or end of the current scene.

Layers

A CCLayer has a size of the whole drawable area, and knows how to draw itself. It can be semi transparent (having holes and/or partial transparency in some/all places), allowing to see other layers behind it. Layers are the ones defining appearance and behavior, so most of your programming time will be spent coding CCLayer subclasses that do what you need.

Alt text

diff --git a/doc/how_to_add_a_sprite.html b/doc/how_to_add_a_sprite.html index c30155f..344d1df 100644 --- a/doc/how_to_add_a_sprite.html +++ b/doc/how_to_add_a_sprite.html @@ -4,7 +4,7 @@

How to Add a sprite


The source code of these tutorials is here: https://github.com/lihex/Cocos2dxSimpleGame. You can follow the articles to finish the game by yourself step by step, or download the finally source, simply build and run it.

1.Add image resources

-

Here¡¯re three images made by Ray Wenderlich ¡¯s wife , which would be used in SimpleGame.

+

Here're three images made by Ray Wenderlich's wife , which would be used in SimpleGame.

Alt text Alt text Alt text

@@ -43,7 +43,7 @@

2.Add a sprite

return bRet; } -

Well, we can build and run the code. Now the ninja is dressed in black, hidden in the black background with red eyes. For the gameplay, we had to change the background to white. It¡¯s so easy, modify HelloWorld to inherit from CCLayerColor instead of CCLayer.

+

Well, we can build and run the code. Now the ninja is dressed in black, hidden in the black background with red eyes. For the gameplay, we had to change the background to white. [[It's]] so easy, modify HelloWorld to inherit from CCLayerColor instead of CCLayer.

At first, modify the declaration in HelloWorldScene.h

     // cpp with cocos2d-x
      class HelloWorld : public cocos2d::CCLayerColor
diff --git a/doc/how_to_detect_the_Collisions.html b/doc/how_to_detect_the_Collisions.html
index 4786d15..4ea0ca9 100644
--- a/doc/how_to_detect_the_Collisions.html
+++ b/doc/how_to_detect_the_Collisions.html
@@ -4,7 +4,7 @@ 

How to Detect the Collisions


Our hero could fire bullets now, but the bullets are only visually there, how could they kill the enemies?

In this chapter, we will introduce Collision Detection to implement it.

-

Firstly, it¡¯s necessary to track the enemies and the bullets.

+

Firstly, it's necessary to track the enemies and the bullets.

In the game, we add a tag for these two kinds of sprites to identify them. tag = 1 stands for a enemy, and tag = 2 means a bullet. Because there is already a member named m_nTag of CCNode, and the methods setTag() and getTag() also exist, CCSprite has inherited them, which we could utilize.

Add the two member variabls below to HelloWorld in HelloWorldScene.h, these two member variables are used to store the existing enemies and bullets.

     // cpp with cocos2d-x
diff --git a/doc/how_to_play_music_and_sund_effect.html b/doc/how_to_play_music_and_sund_effect.html
index c96bccd..7dcf6b1 100644
--- a/doc/how_to_play_music_and_sund_effect.html
+++ b/doc/how_to_play_music_and_sund_effect.html
@@ -3,8 +3,8 @@
 

How to play music and sund effect


In this chapter, we would add background music to the game and play sound effect when the hero fires bullets.

-

Because there¡¯s so few codes to add that we could say a little more about audio engine here. Cocos2d-x has wrapped SimpleAudioEngine to cross platforms. In our game, we are able to play music and sound effect using only one line of codes. It is so convenient. Of course, audio formats supported in different platform are different, about this issue, you could refer to Audio_formats_supported_by_CocosDenshion_on_different_platforms.

-

Now let¡¯s get right to the issues. +

Because there is so few codes to add that we could say a little more about audio engine here. Cocos2d-x has wrapped SimpleAudioEngine to cross platforms. In our game, we are able to play music and sound effect using only one line of codes. It is so convenient. Of course, audio formats supported in different platform are different, about this issue, you could refer to Audio_formats_supported_by_CocosDenshion_on_different_platforms.

+

Now let's get right to the issues. First, copy the sound files background-music-aac.wav and pew-pew-lei.wav to the Resource directory. We use wav here because wav is supported in all platforms and these two files have been included in the Cocos2dSimpleGame project, you could download them from the bottom of this page. Then include SimpleaudioEngine.h in HelloWorldScene.cpp.

     // cpp with cocos2d-x
diff --git a/doc/index.html b/doc/index.html
index 01f97d5..23a7a01 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -19,5 +19,5 @@ 

Create A Simple Game Step By Step

  • Chapter 5 - How to Detect the Collisions
  • Chapter 6 - How to Play Music and Sound Effect
  • -

    created by cocos2d-x.org 2012-07-24
    +

    created by cocos2d-x.org 2012-07-26

    \ No newline at end of file