From: http://blog.csdn.net/kennyliang123/article/details/7957458
The cocos2d-x provides two macros for the cclayer subclass to generate the cclayer Node Method.
# The Node Method generated by the macro define layer_node_func (layer) does not contain parameters. The subclass must have an Init () method without parameters.
# Define layer_node_func_param (layer ,__ paramtype __,__ Param _) the macro-generated node method has parameters. The subclass must have an init method with the same parameters.
[Plain] View plaincopy
- Class backgroundlayer: Public cclayer
- {
- Public:
- Layer_node_func (backgroundlayer );
- Layer_node_func_param (backgroundlayer, ccstring *, ID );
- Virtual bool Init ();
- Virtual bool Init (ccstring * ID );
- };
Usage:
[Plain] View plaincopy
- backgroundlayer = backgroundlayer: node ();
- This-> addchild (backgroundlayer);
-
- backgroundlayer = backgroundlayer: node (m_scnid);
- This-> addchild (backgroundlayer);