1 /* 2 * 该类用于实现游戏中统一的控件实例化方法 3 */ 4 /* 5 * 颜色 6 */ 7 var black = cc.color.BLACK; 8 var blue = cc.color.BLUE; 9 var green = cc.color.GREEN; 10 var orange = cc.color.ORANGE; 11 var pink = cc.color(255, 0, 255, 255);//粉红 12 var purple = cc.color(128, 64, 246, 255);//紫色 13 var red = cc.color.RED; 14 var white = cc.color.WHITE; 15 var yellow = cc.color.YELLOW; 16 17 /* 18 * 显示文本 19 */ 20 var myText = function(str, color, fontSize) 21 { 22 var text = ccui.Text.create(); 23 text.setText(str); 24 text.setColor(color); 25 text.setFontSize(fontSize); 26 text.setAnchorPoint(0, 0); 27 return text; 28 }; 29 30 /* 31 * 图片 32 */ 33 var myImage = function(source) 34 { 35 var image = ccui.ImageView.create(); 36 image.loadTexture(source); 37 image.setAnchorPoint(0, 0); 38 return image; 39 }; 40 41 /* 42 * 按钮 43 */ 44 var myButton = function(texture) 45 { 46 var btn = ccui.Button.create(); 47 btn.loadTextures(texture, ""); 48 btn.setAnchorPoint(0, 0); 49 return btn; 50 };