0
下に四角形を描画:例えばI青(又は赤)長方形上記白色数としてスコアを描画しようとしている単語ゲームでPIXI.Text
、上記のスクリーンショットであります数字「13」。ここで
(現在はハードコードWIDTH
とHEIGHT
と)私のクラス全体Score.js
です:
"use strict";
function Score(color) {
PIXI.Container.call(this);
this.interactive = false;
this.buttonMode = false;
this.visible = false;
this.bgGraphics = new PIXI.Graphics();
this.bgGraphics.beginFill(color, 1);
this.bgGraphics.drawRect(0, 0, Score.WIDTH, Score.HEIGHT);
this.bgGraphics.endFill();
this.addChild(this.bgGraphics);
this.text = new PIXI.Text('XXX', {font: '20px Arial', fill: 0xFFFFFF});
this.text.x = 1;
this.text.y = 1;
this.addChild(this.text);
}
Score.prototype = Object.create(PIXI.Container.prototype);
Score.prototype.constructor = Score;
Score.WIDTH = 36;
Score.HEIGHT = 24;
Score.prototype.setText = function(str) {
this.text.text = str;
}
私は新しい矩形が各呼び出し上に描画されるように、私のsetText()
機能を変更する方法を、不思議 - 境界としてstr
引数の長方形ですか?
私はPIXI.Text.getBounds()方法を見てきたが、それは、私はあなただけthis.text.width
を使用することができると思うMatrix
なくRectangle
...