Document directory
- 2. When is CCB loaded?
- 4. the correspondence of several commonly used cocos2d-x units in C ++ and JS (jsb_coco2d.js)
- 5. Type
- 6. Dynamic
1. MVC mode in cocosbuilder and JavaScript
VaR scene = cc. builderreader. loadasscene ("checkupdatelayer ");
VaR layer = cc. builderreader. Load ("checkupdatelayer ");
These two lines of code are loaded into scene and layer respectively.
In general, we will create a checkupdatelayer. JS. Note that the "checkupdaelayer" entered in "JS controller" is not a layer, but a real controller, because cocosbuilder adopts the MVC mode.
For example, if you add a method in checkupdatelayer. JS, as follows:
Checkupdatelayer. Prototype. Foo = function (){
Cc. Log ("this is afunction ");
}
This Foo method is actually a controller method, not a layer or scene method.
2. When is CCB loaded?
Checkupdatelayer. Prototype. ondidloadfromccb =
Function (){
Cc. Log ("checkupdatelayerinit ");
VaR L = cc. layercolor. Create (CC. C3b (33,233, 0 ),
200,200 );
This. rootnode. addchild (L );
}
Open jsb_cocosbuilder.js and find the CC. builderreader. Load Method. You will see the answer to your questions.
3. generated/cocos2dxapi. js all error.
The classes in are all prefixed with CC, such as CC. ccnode, CC. cclayer, CC. ccsprite, but actually in JS, there is no prefix, such as CC. node, CC. layer, CC. sprite, etc...
4. the correspondence of several commonly used cocos2d-x units in C ++ and JS (jsb_coco2d.js)
C ++ |
Javascript |
Cclog |
Cc. Log |
Ccc3 |
Cc. C3b |
Ccc4 |
Cc. C4B |
Ccc4f |
Cc. c4f |
CCP |
Cc. p |
Ccsize (W, H) |
Cc. Size |
Ccrect (X, Y, W, H) |
Cc. rect |
5. Type
Javascript is a weak type language, and no ccarray or ccdictionary is available here, because any JavaScript Object has the basic features of arrays and dictionaries.
6. Dynamic
When writing C ++, I envy the dynamic characteristics of objective-C. For example, nslog (@ "% @", OBJ) can output the description of the object. but in Javascript, everything is cloudification and CC. dump can meet your needs.
7. Look at the cocos2d-2.1beta3-x-2.1.1/samples/JavaScript in a few demos, will solve your 90% questions.