mirror of
https://github.com/wassname/phaser.git
synced 2026-08-04 13:14:14 +08:00
Text.lineSpacing allows you to control the spacing between each line that is rendered.
Text.inputEnabled allows you to enable all input events over Text objects: dragging, clicking, etc - anything that works on a Sprite works on Text now too.
This commit is contained in:
@@ -784,7 +784,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "renderOrderID", {
|
||||
});
|
||||
|
||||
/**
|
||||
* By default an Image won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
|
||||
* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
|
||||
* activated for this object and it will then start to process click/touch events and more.
|
||||
*
|
||||
* @name Phaser.Sprite#inputEnabled
|
||||
|
||||
@@ -86,6 +86,16 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
*/
|
||||
this._lineSpacing = 0;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components.
|
||||
*/
|
||||
this.events = new Phaser.Events(this);
|
||||
|
||||
/**
|
||||
* @property {Phaser.InputHandler|null} input - The Input Handler for this object. Needs to be enabled with image.inputEnabled = true before you can use it.
|
||||
*/
|
||||
this.input = null;
|
||||
|
||||
PIXI.Text.call(this, text, style);
|
||||
|
||||
this.position.set(x, y);
|
||||
@@ -689,3 +699,39 @@ Object.defineProperty(Phaser.Text.prototype, 'shadowBlur', {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* By default a Text object won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
|
||||
* activated for this object and it will then start to process click/touch events and more.
|
||||
*
|
||||
* @name Phaser.Text#inputEnabled
|
||||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, "inputEnabled", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (this.input === null)
|
||||
{
|
||||
this.input = new Phaser.InputHandler(this);
|
||||
this.input.start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.input && this.input.enabled)
|
||||
{
|
||||
this.input.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user