The Cocos2d-x Programmers Guide

so short to remember
replace replaces the entire scene with new scene
whereas push scene puts a new scene above the current scene and pauses the underlying scene operation
pop scene will remove the top scene from the stack and resume the operation of the underlying scene

1 Like

There is no popScene, which takes a scene as a parameter, only popScene(). It basically ends the current scene, removes it from memory and resumes the scene, which was added before it, or terminates the program, if it was the only scene.
But I guess you were referring to pushScene!?

The difference between pushScene and replaceScene lies in the scene handling.
Pushscene pushes the new scene onto the stack, which preserves the old scene. The newly pushed scene becomes the actual scene, which will be runned. You can always go back to the old scene.
ReplaceScene ends the current scene, removes it from memory and runs the new scene. You cannot go back to the old scene.

@pabitrapadhy
@iQD
Heyā€¦ did u see the below in my last postā€¦ I also earlier felt that popScene() doesnot take any parametersā€¦ but see this below it was mentioned in the guide. :smiley:

Yeah, I saw it. The guide is just plain wrong.

Even the description is wrong:

// popScene - This scene will replace the running one.

This description would suggest, that you get top scene of the stack and it will replace the current one, which is totally not the case.
The running scene will not be replaced at all. The scene at the top of the stack, after popping the current scene, will just be run and the popped scene will be deleted.

I guess they wanted to say: This will replace the running one. Not all cocos2d-x developers are English speakers. so things sometimes get a little wacky.

It would not even make sense, to have a parameter for popping something from the stack. If so, it would not be a stack pop, but direct access into the stack.

Hi Everyone,

Can anyone give Chapter 2 a read and provide feedback?

Some of my suggestions for chapter 2:

Scene Graph section:

  1. typo mistake: 2 or 1 in this example code:

// Adds a child with the z-order of 2, that means
// it goes to the ā€œrightā€ side of the tree (because it is positive)
scene->addChild(sprite_node, 1);

  1. typo mistake: in the tree picture describe all component, i thinks you miss the label node: Super Cocos Alien

  2. suggest for more the detail: in last picture, i think you should add a downward arrow (from the top of picture) with a note: ā€œthe most left node of the tree appears firstā€ or something like that,

And at the bottom of the pic, an upward arrow with a note: ā€œthe most right node appears last, but it will appear on top of the screen and have a chance to hide another nodes which have the same position but below it.ā€

Sprites section:

  1. more details: i think you should add a NOTE at the last line of this section which will mention our engine coordinate system will start from bottom left no matter what the orientation of devices are (portrait or landscape).

Parent Child section:

  1. more details: i think you should have an example mention how to establish parent child relation ship at the end of this section

p/s: IMHO, this section is nearly perfect, keep doing your best, best regards!

Thanks for the feedback!

I finally got around doing a chapter to explain how to build with Gradle and Android Studio (sent a pull request here https://github.com/chukong/programmers-guide/pull/47). It would be great if someone could test it on Windows and Linux.

@slackmoehrle I was thinking about contributing a chapter about using native features, which explains the relationship between C++ and Objective-C and how to use JNI to call Java code. Is it a problem if it only covers iOS and Android? I donā€™t develop on other platforms, unfortunately.

1 Like

I donā€™t think it is a problem for now. Please do. We can always work on other platforms later and maybe someone in the community can help at that point too. Thanks for the contribution.

Good read! Itā€™s really helpful for beginners like me.

Especially liked the Chapter 2, itā€™s perfect! I have been wondering myself why donā€™t we use node instead of sprite, now that is answered.

Chapter 3, there are some grammar mistakes ? Misconception between effect and affect.

Chapter 4 - Reversing spawn
I think we are referring to the actions within the spawn not the spawn itself as those actions run all @ e same time. E.g the spawn contain EaseIn and FadeIn then it will be EaseOut and FadeOut.
Correct me if Im wrong, I have not try this, my first encounter with spawn, thanks :slight_smile:

Chapter 7 - Parallax
I finally undertand how it works! It would be better if we could have an image depicting what the code is trying to show.

Chapter 8 - Swallow Touches
Maybe we can explain on why onTouchBegan() should return true; ? Im not very sure here, Im assuming that if it return true the event is consumed by that object else it will move to the next priority object ? I remember having this issue with my first game, since then Iā€™d put return true; for all onTouchBegan() without knowing what it is actually for.

Just came back and surprised to find this guide :slight_smile:

Very thankful for the guide. Itā€™s awesome!
Will give more feedback once I have read the rest of the remaining chapters. Cheers to the cocos2dx community!

Great.

I merged a PR that fixed this then I also re-read it myself again this morning. Thank you.

Iā€™ll have a look.

This chapter is under development.

let me have a look.

It is actually starting to go live: http://cocos2d-x.org/programmersguide/

Looks quite nice. Who did the images? Iā€™m missing the style and quality from the cocos website :wink:

what images are you referring to?

The logos, icons and assets from the website:
http://files.cocos2d-x.org/images/orgsite/banner_js_v3.png?1410404873

http://files.cocos2d-x.org/images/orgsite/banner_3_2.png?1405419609
http://cocos.com/assets/landing-e1beb42eb0f51141365b7168043b3de3.png

compared to those:
http://cocos2d-x.org/programmersguide/2/2n_main.png

Why is not the same artist doing the assets?

The pictures on the frontpage are very well designed to be an eyecatcher. The pictures in tutorials or programming guides donā€™t need to be an eyecatcher, they must deliver value.

Andā€¦ I donā€™t think the pictures arenā€™t that bad! Mine are worse :stuck_out_tongue_winking_eye:

1 Like

Value is delivered by awesomeness :smiley:

Iā€™m not saying they are that bad, but they should resemble the style and art of the homepage. Maybe you donā€™t even want to see mine :smile:

1 Like

Back at my think tank I had this, well, kinda crazy idea:
How about making a (AAA) game with the community, beginning at the design phase, throughout programming until releasing it on the stores. If the game will generate money, it can be used to create other tutorials and even wright a book? :smile:

This way people would see and learn how a professional game is made form the start to the beginning. Game design, Sprite creation, Animation, Programming, Encryption usage, SDKs usage and what not.

The question is, if this would be feasible and if there are people out there, who would be willing to make it happen/contribute.
Even if it would take a long time, it would be a challenge.

@slackmoehrle You mentioned some time ago, that the programming guide would teach you how to make a game. Can I hope it will be a ā€œMetal Slugā€ like game? :wink:

1 Like

This would be the most brilliant ideaā€¦ and even more if it is actually doneā€¦
I doubt if learnt people will contribute their time for thisā€¦
I mean, the small game projects doesnot help too much to even make professional looking game or for multiple device or to make it available at the play stores for earning few money.

So, beginners remain at beginners unless they invest their hell lot of timeā€¦
But but with this kind of complete professional game project anyone doing cocos2d-x can learn anything and will be very very much helpful for indie people

I think we should go for it if other learnt people are ready to invest their valuable timeā€¦ We can release those game under cocos2d-x nameā€¦ infact we donā€™t have to release the game, we can ask moderators to do so under cocos2d-x accountā€¦ and yes the money if it fetches then they know how to invest it for more support in learningā€¦

I think metal slug would be a hell lot of game. And I think aim of the programmerā€™s guide is more on teaching concepts and APIs of cocos2d-x rather than making a professional gameā€¦
Lets decide a game(not AAA but a very good professional looking game) and ask people if they are willing to make such a game for the community.

I would love to be part of such a projectā€¦
If it is started do include meā€¦ we can discuss things. Also,I may even help in designing a few nice looking charactersā€¦ :smiley: in inkscape and somewhat photoshop

Yeah. Thatā€™s the spirit of OpenSource :smiley:

Thatā€™s the hardest part, as professional people are not free. In the end, we could always look into crowd funding.

Well, the game shout stay in the hands of the community. If it generates money, the community will get it.
If there were just two people in the community, they will get the bucks, but have to invest it into the community again.
I guess there are hardly any professional people out there, accepting on such a deal :wink:

It would be the same as a donation to some OpenSource project, but the donations being the generated money at the stores.

Sure. How about some ā€œSuper Metroidā€? :wink:

There are plenty of old school games out there, that would be awesome in full HD :smiley:.

But you are correct about the programming guide. But you know, concepts are concepts and real applications are real applications. Iā€™m sure many people know the concepts of space travel, but how many can build something out of it?

I just mentioned AAA because it is just a ridiculous term used all over the media. If games like " bird" is making more money, than the blockbuster games from the big players, isnā€™t that AAA term a little misleading?

The community would have to decide, which game(to get the most out of it), I guess.

So, the hardest part is on you then ;-).

Do you have a portfolio?

Yeah, I think the sameā€¦

I donā€™t work as professional artistā€¦ I do it mostly as my hobby or for my game projects and can show you a few characters but in PMā€¦
Check out your PMā€¦