Add: TabLayout
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
// BasicTab.prototype = Object.create();
|
||||
BasicTab.constructor = BasicTab;
|
||||
|
||||
function BasicTab(setting, clickEvent) {
|
||||
function BasicTab() {
|
||||
this.activate = true;
|
||||
|
||||
this.buttonSprite = null;
|
||||
this.activeLineSprite = null;
|
||||
|
||||
this.iconSprite = null;
|
||||
|
||||
this.mainText = null;
|
||||
this.shortcutText = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BasicTab.prototype.createButton = function(setting, clickEvent) {
|
||||
this.setting = setting;
|
||||
this.clickEvent = clickEvent;
|
||||
|
||||
this.activate = true;
|
||||
|
||||
// button sprite
|
||||
this.buttonSprite = this.makeButtonSprite();
|
||||
this.setEventMethod(this.buttonSprite);
|
||||
|
||||
this.activeSprite = this.makeActiveSprite();
|
||||
this.setEventMethod(this.activeSprite);
|
||||
|
||||
|
||||
this.iconSprite = null;
|
||||
this.mainText = null;
|
||||
this.shortcutText = null;
|
||||
|
||||
this.activeLineSprite = this.makeActiveLineSprite();
|
||||
this.setEventMethod(this.activeLineSprite);
|
||||
|
||||
this.mainText = this.makeMainText();
|
||||
this.buttonSprite.addChild(this.mainText);
|
||||
@@ -31,8 +37,6 @@ function BasicTab(setting, clickEvent) {
|
||||
this.mouseOut();
|
||||
}
|
||||
|
||||
|
||||
|
||||
BasicTab.prototype.makeButtonSprite = function() {
|
||||
var setting = this.setting;
|
||||
// console.log("strokeWidthPx : " + setting.strokeWidthPx);
|
||||
@@ -58,12 +62,12 @@ BasicTab.prototype.makeButtonSprite = function() {
|
||||
return buttonSprite;
|
||||
}
|
||||
|
||||
BasicTab.prototype.makeActiveSprite = function() {
|
||||
BasicTab.prototype.makeActiveLineSprite = function() {
|
||||
var setting = this.setting;
|
||||
// console.log("strokeWidthPx : " + setting.strokeWidthPx);
|
||||
// console.log("round : " + setting.roundAmount);
|
||||
|
||||
var OFFSET_POS_Y = 12;
|
||||
var OFFSET_POS_Y = 7;
|
||||
|
||||
var buttonWidth = setting.width;
|
||||
var lineWidth = buttonWidth * 3 / 4;
|
||||
@@ -71,19 +75,20 @@ BasicTab.prototype.makeActiveSprite = function() {
|
||||
|
||||
var texture = null;
|
||||
texture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff)
|
||||
// .beginFill(0xffffff)
|
||||
.beginFill(MainColor.LIGHT_CHOCO_HEX)
|
||||
.drawRoundedRect(0, 0, lineWidth, lineHeight, 1)
|
||||
.endFill()
|
||||
.generateTexture();
|
||||
|
||||
var posX = setting.x - lineWidth / 2;
|
||||
var posY = setting.y + setting.height / 2 - OFFSET_POS_Y;
|
||||
var activeSprite = game.add.sprite(posX, posY, texture);
|
||||
var activeLineSprite = game.add.sprite(posX, posY, texture);
|
||||
|
||||
// buttonSprite.anchor.setTo(0.5, 0.5);
|
||||
activeSprite.inputEnabled = true;
|
||||
activeLineSprite.inputEnabled = true;
|
||||
|
||||
return activeSprite;
|
||||
return activeLineSprite;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +100,6 @@ BasicTab.prototype.addIcon = function(spriteName) {
|
||||
if(spriteName.length === 0)
|
||||
return;
|
||||
|
||||
console.log("addIcon : " + spriteName);
|
||||
this.iconSprite = game.add.sprite(0, 0, spriteName);
|
||||
this.iconSprite.x = this.buttonSprite.width / 2;
|
||||
this.iconSprite.y = this.buttonSprite.height / 2;
|
||||
@@ -186,9 +190,9 @@ BasicTab.prototype.setActive = function(flag) {
|
||||
this.activate = flag;
|
||||
|
||||
if(this.activate)
|
||||
this.activeSprite.alpha = 1;
|
||||
this.activeLineSprite.alpha = 1;
|
||||
else
|
||||
this.activeSprite.alpha = 0;
|
||||
this.activeLineSprite.alpha = 0;
|
||||
}
|
||||
|
||||
BasicTab.prototype.alignContents = function() {
|
||||
@@ -270,7 +274,7 @@ BasicTab.prototype.mouseOut = function() {
|
||||
if(this.shortcutText !== undefined)
|
||||
this.shortcutText.fill = this.setting.textColors.out;
|
||||
|
||||
this.activeSprite.tint = this.setting.activeColors.out;
|
||||
// this.activeLineSprite.tint = this.setting.activeColors.out;
|
||||
}
|
||||
|
||||
BasicTab.prototype.mouseOver = function() {
|
||||
@@ -283,7 +287,7 @@ BasicTab.prototype.mouseOver = function() {
|
||||
if(this.shortcutText !== undefined)
|
||||
this.shortcutText.fill = this.setting.textColors.over;
|
||||
|
||||
this.activeSprite.tint = this.setting.activeColors.over;
|
||||
// this.activeLineSprite.tint = this.setting.activeColors.over;
|
||||
}
|
||||
|
||||
BasicTab.prototype.mouseDown = function() {
|
||||
@@ -296,7 +300,7 @@ BasicTab.prototype.mouseDown = function() {
|
||||
if(this.shortcutText !== undefined)
|
||||
this.shortcutText.fill = this.setting.textColors.down;
|
||||
|
||||
this.activeSprite.tint = this.setting.activeColors.down;
|
||||
// this.activeLineSprite.tint = this.setting.activeColors.down;
|
||||
}
|
||||
|
||||
BasicTab.prototype.buttonDisabled = function() {
|
||||
@@ -309,7 +313,7 @@ BasicTab.prototype.buttonDisabled = function() {
|
||||
if(typeof this.shortcutText !== undefined)
|
||||
this.shortcutText.fill = this.setting.textColors.disabled;
|
||||
|
||||
this.activeSprite.tint = this.setting.activeColors.disabled;
|
||||
// this.activeLineSprite.tint = this.setting.activeColors.disabled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user