mirror of
https://github.com/wassname/phaser.git
synced 2026-07-03 17:10:40 +08:00
TileSprites can now receive full Input events, dragging, etc and be positioned in-world and fixed to cameras (fixes #321)
This commit is contained in:
@@ -83,6 +83,11 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
|
||||
|
||||
this.position.set(x, y);
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
|
||||
*/
|
||||
@@ -418,3 +423,39 @@ Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* By default a TileSprite 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.TileSprite#inputEnabled
|
||||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.TileSprite.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