Add: ChocoSettingButton

This commit is contained in:
2019-07-25 10:53:57 +09:00
parent 1df8fba0a5
commit c5ddd81e7d
6 changed files with 90 additions and 15 deletions
+28 -10
View File
@@ -29,11 +29,20 @@ function ChocoButton(setting, clickEvent) {
ChocoButton.prototype.makeButtonStrokeSprite = function() { // outter(bigger) round rect sprite
var texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRoundedRect(0, 0, this.setting.width, this.setting.height, this.setting.roundAmount)
.endFill()
.generateTexture();
var texture = null;
if(this.setting.roundAmount === 0) {
texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRect(0, 0, this.setting.width, this.setting.height)
.endFill()
.generateTexture();
} else {
texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRoundedRect(0, 0, this.setting.width, this.setting.height, this.setting.roundAmount)
.endFill()
.generateTexture();
}
var buttonStrokeSprite = game.add.sprite(
this.setting.x - this.setting.width / 2,
@@ -58,11 +67,20 @@ ChocoButton.prototype.makeButtonSprite = function() { // inner(smaller) round re
var longSideButton = (btnWidth > btnHeight ? btnWidth : btnHeight);
var btnRoundAmount = setting.roundAmount * longSideButton / longSideStroke;
var texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRoundedRect(0, 0, btnWidth, btnHeight, btnRoundAmount)
.endFill()
.generateTexture();
var texture = null;
if(this.setting.roundAmount === 0) {
texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRect(0, 0, btnWidth, btnHeight)
.endFill()
.generateTexture();
} else {
texture = new Phaser.Graphics()
.beginFill(0xffffff)
.drawRoundedRect(0, 0, btnWidth, btnHeight, btnRoundAmount)
.endFill()
.generateTexture();
}
var posX = setting.x - btnWidth / 2;
var posY = setting.y - btnHeight / 2;