Hi,
I’m reading the code of MoonWarriors to learn how to use JS to write a Cocos2D-X game sandbox; Sorry if this question is more about JS than CC2D-x!
As I open GameLayer for instance, I see that functions can be added in three different ways. I try to understand the added value of each approach…
First approach I see is in the extend parameter:
`var GameLayer = cc.Layer.extend({
processEvent:function( event ) {
//…
},
// …
}`
The second is on that GameLayer (global?) variable:
GameLayer.create = function () { //...
Is this like creating a Class method in Java - Using a common set of data whatever the calling instance is?
BTW, Is this GameLayer a variable/instance, a “class”?
Third approach is about adding “stuff” the the prototype:
GameLayer.prototype.addEnemy = function (enemy,z,tag){
Am I right to understand this is like an instance method in Java or ObjC?
Thanks…
J.