I am confused about layers. so i don’t know whether i am using them correctly or not.
var game = cc.scene.extend({
onEnter: function() {
//here we create a layer for the game.
var layer = gameLayer();
}
});
var gameLayer = cc.Layer.extend({
});
There are the default coding we get during the game creation.
I want to have
Background Layer
Menu Layer
Game Layer
Can i have these layers? Or all should be in one single layer?
Now i can have more layers,
var game = cc.scene.extend({
onEnter: function() {
//here we create a layer for the game.
var layer = gameLayer();
//Background Layer = new BackgroundLayer();
//Do i need to create the additional layers inside the scene? or inside the main gameLayer?
}
});
Please give me simple example to understand the process clearly.
Thanks a lot.
[quote=“agriz, post:1, topic:26885”]
Please give me simple example to understand the process clearly.
[/quote] Good article to understand layers in your game http://www.cocos2d-x.org/wiki/Layer
[quote=“agriz, post:1, topic:26885”]
I want to have
Although most of these articles follow c++, but concept remains the same. Hope this helps, Tell us if you need any other assistance in getting started.
I am afraid there is no JavaScript article(AFAIK) of given link. You have to understand the concept from above articles and code a version of same. I only programmer with c++ so i can’t be of much help may be @slackmoehrle could help you regarding JS version.
I think that you should do this where it makes sense in your game.
Here is what I do:
I have a GameObject class that does not sub-class anything.
As member variables I have a Scene and whatever Layer objects I need. (in the .h/.hpp)
I instantiate the Scene and Layer objects as I need them inside the .cpp. Usually not in the class constructor, but I usually have an init() function, etc.