Fix: RoundRectSetting.x, y
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class RoundRectButtonSetting {
|
||||
|
||||
constructor(width, height, roundAmount) {
|
||||
constructor(x, y, width, height, roundAmount) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.roundAmount = 0;
|
||||
@@ -120,20 +122,24 @@ class RoundRectButton {
|
||||
target.events.onInputUp.add(function() { this.mouseOver(); }, this);
|
||||
}
|
||||
|
||||
makeButtonStroke() {
|
||||
makeButtonStroke() { // outter(bigger) round rect sprite
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff)
|
||||
.drawRoundedRect(0, 0, this.setting.width, this.setting.height, this.setting.roundAmount)
|
||||
.endFill()
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(0, 0, btnTexture);
|
||||
return game.add.sprite(
|
||||
this.setting.x - this.setting.width / 2,
|
||||
this.setting.y - this.setting.height / 2,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
makeButtonSprite() {
|
||||
makeButtonSprite() { // inner(smaller) round rect sprite
|
||||
let width = this.setting.width - this.setting.strokeWidthPx * 2;
|
||||
let height = this.setting.height - this.setting.strokeWidthPx * 2;
|
||||
let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width);
|
||||
let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width / 1.5);
|
||||
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff)
|
||||
@@ -141,7 +147,12 @@ class RoundRectButton {
|
||||
.endFill()
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(0, 0, btnTexture);
|
||||
// return game.add.sprite(0, 0, btnTexture);
|
||||
return game.add.sprite(
|
||||
this.setting.x - this.setting.width / 2 + this.setting.strokeWidthPx,
|
||||
this.setting.y - this.setting.height / 2 + this.setting.strokeWidthPx,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
makeIcon(iconName) {
|
||||
|
||||
Reference in New Issue
Block a user