Extending Layer

Extending Layer
0.0 0



I created a layer called “BaseLayer” which contains all common buttons and labels. I wanted to extend that BaseLayer to all other layers so that redundant code should b removed. But when i say

childLayer = BaseLayer.extend({

its giving console error “BaseLayer is undefined”. I did it by seeing example in “tests”. but the only difference is childLayer and BaseLayer are written in two different files which i loaded in cocos2d.js.

Then I tried with ought extending, Now i can see all buttons and labels, in child layer but they all are disabled. Image click label updates are not working. I declared all labels as global variables and initialized them in baseLayer init() method. In Child layer when i do setString on labels its giving

label is null;

can anyone reply me asap.


Did you extend BaseLayer from layer as a class?

Could you please show more details about your bug?



I am able to resolve it just adding that base node with all common feature as a part all other layers. So all common changes I’ll do in that base node which is working for me. But extend didn’t worked.

But can u please show me the solution for following its really urgent. I have very long text. I want to display it in limited space, and for extra text i should give option of scrolling to user. Can u please show me the solution for it. Can we have scroll bar for TextField? Pls let me know some solution by the EOD.

Thanks in advance.