(function() { "use strict"; function createButton(width, height, text, disalign, style) { var button = new createjs.Container(); style = style || '32px sweetlove'; var boxObj = createBox(width, height, disalign); var textObj = new createjs.Text(text, style, '#6D4419'); textObj.textAlign = 'center'; if (disalign) { var bounds = textObj.getBounds(); // textObj.regX = bounds.width/2; textObj.regY = bounds.height/2; textObj.x = width/2; textObj.y = height/2; // textObj.y = height/2; button.setBounds(0, 0, width, height); } else { var bounds = textObj.getBounds(); // textObj.regX = bounds.width/2; // textObj.regY = bounds.height/2; textObj.x = 0; textObj.y = -height/2; // textObj.y = height/2; } button.addChild(boxObj); button.addChild(textObj); return button; } function createBox(width, height, disalign) { var box = new createjs.Shape(); box.graphics.setStrokeStyle(4, 'round') box.graphics.beginStroke('#6D4419'); box.graphics.beginFill('#FFC602'); if (disalign) box.graphics.drawRect(0, 0, width, height); else box.graphics.drawRect(-width/2, -height/2, width, height); return box; } window.createButton = createButton; window.createBox = createBox; }());