mirror of
https://github.com/wassname/phaser.git
synced 2026-07-19 11:26:26 +08:00
Button now extends Phaser.Image not Phaser.Sprite, all the same functionality as before remains, just no animations or physics body.
This commit is contained in:
@@ -70,6 +70,8 @@ Significant API changes:
|
||||
* Sprite.deltaX and deltaY swapped to functions: Sprite.deltaX() and Sprite.deltaY()
|
||||
* Sprite.crop() now takes a Phaser.Rectangle instead of explicit parameters.
|
||||
* PixiPatch no longer needed, all features that it patched are now native in Pixi :)
|
||||
* Removed: Sprite.offset, center, topLeft, topRight, bottomRight, bottomLeft and bounds as no longer needed internally. Use Sprite.getBounds() to derive them.
|
||||
* Button now extends Phaser.Image not Phaser.Sprite, all the same functionality as before remains, just no animations or physics body.
|
||||
|
||||
|
||||
New features:
|
||||
|
||||
@@ -78,17 +78,17 @@ function changeSky (button) {
|
||||
|
||||
function render () {
|
||||
|
||||
game.debug.renderSpriteCorners(button1, false, true);
|
||||
game.debug.renderSpriteCorners(button2, false, true);
|
||||
game.debug.renderSpriteCorners(button3, false, true);
|
||||
game.debug.renderSpriteCorners(button4, false, true);
|
||||
game.debug.renderSpriteCorners(button5, false, true);
|
||||
game.debug.renderSpriteCorners(button6, false, true);
|
||||
// game.debug.renderSpriteCorners(button1, false, true);
|
||||
// game.debug.renderSpriteCorners(button2, false, true);
|
||||
// game.debug.renderSpriteCorners(button3, false, true);
|
||||
// game.debug.renderSpriteCorners(button4, false, true);
|
||||
// game.debug.renderSpriteCorners(button5, false, true);
|
||||
// game.debug.renderSpriteCorners(button6, false, true);
|
||||
|
||||
// game.debug.renderWorldTransformInfo(button1, 32, 132);
|
||||
// game.debug.renderText('sx: ' + button3.scale.x + ' sy: ' + button3.scale.y + ' w: ' + button3.width + ' cw: ' + button3._cache.width, 32, 20);
|
||||
game.debug.renderText('ox: ' + game.stage.offset.x + ' oy: ' + game.stage.offset.y, 32, 20);
|
||||
game.debug.renderPoint(button3.input._tempPoint);
|
||||
game.debug.renderPoint(button6.input._tempPoint);
|
||||
// game.debug.renderText('ox: ' + game.stage.offset.x + ' oy: ' + game.stage.offset.y, 32, 20);
|
||||
// game.debug.renderPoint(button3.input._tempPoint);
|
||||
// game.debug.renderPoint(button6.input._tempPoint);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* You can set a unique texture frame and Sound for any of these states.
|
||||
*
|
||||
* @constructor
|
||||
* @extends Phaser.Image
|
||||
*
|
||||
* @param {Phaser.Game} game Current game instance.
|
||||
* @param {number} [x=0] - X position of the Button.
|
||||
@@ -37,7 +38,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
callback = callback || null;
|
||||
callbackContext = callbackContext || this;
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, key, outFrame);
|
||||
Phaser.Image.call(this, game, x, y, key, outFrame);
|
||||
|
||||
/**
|
||||
* @property {number} type - The Phaser Object Type.
|
||||
@@ -180,6 +181,10 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
*/
|
||||
this.forceOut = false;
|
||||
|
||||
this.inputEnabled = true;
|
||||
|
||||
this.input.start(0, true);
|
||||
|
||||
this.setFrames(overFrame, outFrame, downFrame, upFrame);
|
||||
|
||||
if (callback !== null)
|
||||
@@ -187,8 +192,6 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
this.onInputUp.add(callback, callbackContext);
|
||||
}
|
||||
|
||||
this.input.start(0, true);
|
||||
|
||||
// Redirect the input events to here so we can handle animation updates, etc
|
||||
this.events.onInputOver.add(this.onInputOverHandler, this);
|
||||
this.events.onInputOut.add(this.onInputOutHandler, this);
|
||||
@@ -197,8 +200,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
|
||||
};
|
||||
|
||||
Phaser.Button.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Button.prototype, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
|
||||
Phaser.Button.prototype = Object.create(Phaser.Image.prototype);
|
||||
Phaser.Button.prototype.constructor = Phaser.Button;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user