Scale9sprite
When using Scale9sprite.create uncaught typeerror:cannot call method ' create ' of undefined this error,
It was later found that by default, the modules in Project.json only comes with cocos2d modules, by checking frameworks/cocos2d-html5/ Moduleconfig.json, you can see that there is no ccscale9sprite.js this class in the Cocos2d module.
It's in the GUI, so you can add the "GUI" module to the modules, or it can be like me, In Moduleconfig.json write a myneedfulclass such module, inside add Ccscale9sprite.js this class, so long as the modules add "Myneedfulclass" on the line. One advantage is that you can not load other classes in the GUI. The test code is as follows
var tmp = cc. Sprite.create (Res. BLOCK9); var thesize = tmp.getcontentsize (); var fullrect = Cc.rect (0,0, thesize.width,thesize.height); var insetrect = Cc.rect (32,32,thesize.width-64,thesize.height-64); var scale9sprite = cc. Scale9sprite.create (Res. Block9,fullrect,insetrect); Scale9sprite.setcontentsize (thesize.width*3,thesize.height*2); scale9sprite.x = SIZE.WIDTH/2; Scale9sprite.y = SIZE.HEIGHT/2; this. AddChild (Scale9sprite);
Original Picture:
After the above code processing image:
The effect is a,b,c,d four angular size unchanged, top,bottom two sides of the horizontal stretching, left,right two sides of the longitudinal stretching, center of the Center both transverse and longitudinal stretching.
Used in a more suitable place, such as a button wizard.