mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Updated doc files.
This commit is contained in:
+202
-116
@@ -90,6 +90,10 @@
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
@@ -162,6 +166,14 @@
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
@@ -186,6 +198,10 @@
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
@@ -278,6 +294,10 @@
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
@@ -342,6 +362,10 @@
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -374,36 +398,6 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#bottom">bottom</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#render">render</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#renderXY">renderXY</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#right">right</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -423,7 +417,7 @@
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
@@ -442,16 +436,17 @@
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game Current game instance.
|
||||
* @param {number} [x] - X position of the Button.
|
||||
* @param {number} [y] - Y position of the Button.
|
||||
* @param {number} [x=0] - X position of the Button.
|
||||
* @param {number} [y=0] - Y position of the Button.
|
||||
* @param {string} [key] - The image key as defined in the Game.Cache to use as the texture for this Button.
|
||||
* @param {function} [callback] - The function to call when this Button is pressed.
|
||||
* @param {object} [callbackContext] - The context in which the callback will be called (usually 'this').
|
||||
* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [upFrame] - This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name.
|
||||
*/
|
||||
Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
|
||||
Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
@@ -486,7 +481,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameName = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {string} _onUpFrameName - Internal variable.
|
||||
* @private
|
||||
@@ -514,7 +509,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameID = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} _onUpFrameID - Internal variable.
|
||||
* @private
|
||||
@@ -596,13 +591,13 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
this.freezeFrames = false;
|
||||
|
||||
/**
|
||||
* When the Button is clicked you can optionally force the state to "out".
|
||||
* When the Button is touched / clicked and then released you can force it to enter a state of "out" instead of "up".
|
||||
* @property {boolean} forceOut
|
||||
* @default
|
||||
*/
|
||||
this.forceOut = true;
|
||||
this.forceOut = false;
|
||||
|
||||
this.setFrames(overFrame, outFrame, downFrame);
|
||||
this.setFrames(overFrame, outFrame, downFrame, upFrame);
|
||||
|
||||
if (callback !== null)
|
||||
{
|
||||
@@ -624,15 +619,38 @@ Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Button.prototype, Pha
|
||||
Phaser.Button.prototype.constructor = Phaser.Button;
|
||||
|
||||
/**
|
||||
* Used to manually set the frames that will be used for the different states of the button
|
||||
* exactly like setting them in the constructor.
|
||||
* Clears all of the frames set on this Button.
|
||||
*
|
||||
* @method Phaser.Button.prototype.clearFrames
|
||||
*/
|
||||
Phaser.Button.prototype.clearFrames = function () {
|
||||
|
||||
this._onOverFrameName = null;
|
||||
this._onOverFrameID = null;
|
||||
|
||||
this._onOutFrameName = null;
|
||||
this._onOutFrameID = null;
|
||||
|
||||
this._onDownFrameName = null;
|
||||
this._onDownFrameID = null;
|
||||
|
||||
this._onUpFrameName = null;
|
||||
this._onUpFrameID = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to manually set the frames that will be used for the different states of the Button.
|
||||
*
|
||||
* @method Phaser.Button.prototype.setFrames
|
||||
* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [upFrame] - This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name.
|
||||
*/
|
||||
Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame, upFrame) {
|
||||
|
||||
this.clearFrames();
|
||||
|
||||
if (overFrame !== null)
|
||||
{
|
||||
@@ -661,7 +679,6 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
if (typeof outFrame === 'string')
|
||||
{
|
||||
this._onOutFrameName = outFrame;
|
||||
this._onUpFrameName = outFrame;
|
||||
|
||||
if (this.input.pointerOver() === false)
|
||||
{
|
||||
@@ -671,7 +688,6 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
else
|
||||
{
|
||||
this._onOutFrameID = outFrame;
|
||||
this._onUpFrameID = outFrame;
|
||||
|
||||
if (this.input.pointerOver() === false)
|
||||
{
|
||||
@@ -702,6 +718,28 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
}
|
||||
}
|
||||
|
||||
if (upFrame !== null)
|
||||
{
|
||||
if (typeof upFrame === 'string')
|
||||
{
|
||||
this._onUpFrameName = upFrame;
|
||||
|
||||
if (this.input.pointerUp())
|
||||
{
|
||||
this.frameName = upFrame;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._onUpFrameID = upFrame;
|
||||
|
||||
if (this.input.pointerUp())
|
||||
{
|
||||
this.frame = upFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -723,8 +761,8 @@ Phaser.Button.prototype.setSounds = function (overSound, overMarker, downSound,
|
||||
|
||||
this.setOverSound(overSound, overMarker);
|
||||
this.setOutSound(outSound, outMarker);
|
||||
this.setUpSound(upSound, upMarker);
|
||||
this.setDownSound(downSound, downMarker);
|
||||
this.setUpSound(upSound, upMarker);
|
||||
|
||||
}
|
||||
|
||||
@@ -777,31 +815,7 @@ Phaser.Button.prototype.setOutSound = function (sound, marker) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer clicks on this Button.
|
||||
*
|
||||
* @method Phaser.Button.prototype.setUpSound
|
||||
* @param {Phaser.Sound} sound - The Sound that will be played.
|
||||
* @param {string} [marker] - A Sound Marker that will be used in the playback.
|
||||
*/
|
||||
Phaser.Button.prototype.setUpSound = function (sound, marker) {
|
||||
|
||||
this.onUpSound = null;
|
||||
this.onUpSoundMarker = '';
|
||||
|
||||
if (sound instanceof Phaser.Sound)
|
||||
{
|
||||
this.onUpSound = sound;
|
||||
}
|
||||
|
||||
if (typeof marker === 'string')
|
||||
{
|
||||
this.onUpSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer clicks on this Button.
|
||||
* The Sound to be played when a Pointer presses down on this Button.
|
||||
*
|
||||
* @method Phaser.Button.prototype.setDownSound
|
||||
* @param {Phaser.Sound} sound - The Sound that will be played.
|
||||
@@ -824,25 +838,43 @@ Phaser.Button.prototype.setDownSound = function (sound, marker) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer has pressed down and is released from this Button.
|
||||
*
|
||||
* @method Phaser.Button.prototype.setUpSound
|
||||
* @param {Phaser.Sound} sound - The Sound that will be played.
|
||||
* @param {string} [marker] - A Sound Marker that will be used in the playback.
|
||||
*/
|
||||
Phaser.Button.prototype.setUpSound = function (sound, marker) {
|
||||
|
||||
this.onUpSound = null;
|
||||
this.onUpSoundMarker = '';
|
||||
|
||||
if (sound instanceof Phaser.Sound)
|
||||
{
|
||||
this.onUpSound = sound;
|
||||
}
|
||||
|
||||
if (typeof marker === 'string')
|
||||
{
|
||||
this.onUpSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function that handles input events.
|
||||
*
|
||||
* @protected
|
||||
* @method Phaser.Button.prototype.onInputOverHandler
|
||||
* @param {Phaser.Button} sprite - The Button that the event occured on.
|
||||
* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputOverHandler = function (pointer) {
|
||||
Phaser.Button.prototype.onInputOverHandler = function (sprite, pointer) {
|
||||
|
||||
if (this.freezeFrames === false)
|
||||
{
|
||||
if (this._onOverFrameName != null)
|
||||
{
|
||||
this.frameName = this._onOverFrameName;
|
||||
}
|
||||
else if (this._onOverFrameID != null)
|
||||
{
|
||||
this.frame = this._onOverFrameID;
|
||||
}
|
||||
this.setState(1);
|
||||
}
|
||||
|
||||
if (this.onOverSound)
|
||||
@@ -861,20 +893,14 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) {
|
||||
*
|
||||
* @protected
|
||||
* @method Phaser.Button.prototype.onInputOverHandler
|
||||
* @param {Phaser.Button} sprite - The Button that the event occured on.
|
||||
* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputOutHandler = function (pointer) {
|
||||
Phaser.Button.prototype.onInputOutHandler = function (sprite, pointer) {
|
||||
|
||||
if (this.freezeFrames === false)
|
||||
{
|
||||
if (this._onOutFrameName != null)
|
||||
{
|
||||
this.frameName = this._onOutFrameName;
|
||||
}
|
||||
else if (this._onOutFrameID != null)
|
||||
{
|
||||
this.frame = this._onOutFrameID;
|
||||
}
|
||||
this.setState(2);
|
||||
}
|
||||
|
||||
if (this.onOutSound)
|
||||
@@ -893,20 +919,14 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) {
|
||||
*
|
||||
* @protected
|
||||
* @method Phaser.Button.prototype.onInputOverHandler
|
||||
* @param {Phaser.Button} sprite - The Button that the event occured on.
|
||||
* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputDownHandler = function (pointer) {
|
||||
Phaser.Button.prototype.onInputDownHandler = function (sprite, pointer) {
|
||||
|
||||
if (this.freezeFrames === false)
|
||||
{
|
||||
if (this._onDownFrameName != null)
|
||||
{
|
||||
this.frameName = this._onDownFrameName;
|
||||
}
|
||||
else if (this._onDownFrameID != null)
|
||||
{
|
||||
this.frame = this._onDownFrameID;
|
||||
}
|
||||
this.setState(3);
|
||||
}
|
||||
|
||||
if (this.onDownSound)
|
||||
@@ -925,29 +945,76 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) {
|
||||
*
|
||||
* @protected
|
||||
* @method Phaser.Button.prototype.onInputOverHandler
|
||||
* @param {Phaser.Button} sprite - The Button that the event occured on.
|
||||
* @param {Phaser.Pointer} pointer - The Pointer that activated the Button.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputUpHandler = function (pointer) {
|
||||
|
||||
if (this.freezeFrames === false)
|
||||
{
|
||||
if (this._onUpFrameName != null)
|
||||
{
|
||||
this.frameName = this._onUpFrameName;
|
||||
}
|
||||
else if (this._onUpFrameID != null)
|
||||
{
|
||||
this.frame = this._onUpFrameID;
|
||||
}
|
||||
}
|
||||
Phaser.Button.prototype.onInputUpHandler = function (sprite, pointer, isOver) {
|
||||
|
||||
if (this.onUpSound)
|
||||
{
|
||||
this.onUpSound.play(this.onUpSoundMarker);
|
||||
}
|
||||
|
||||
if (this.forceOut && this.freezeFrames === false)
|
||||
if (this.onInputUp)
|
||||
{
|
||||
this.onInputUp.dispatch(this, pointer, isOver);
|
||||
}
|
||||
|
||||
if (this.freezeFrames)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.forceOut)
|
||||
{
|
||||
// Button should be forced to the Out frame when released.
|
||||
this.setState(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._onUpFrameName || this._onUpFrameID)
|
||||
{
|
||||
this.setState(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isOver)
|
||||
{
|
||||
this.setState(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setState(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function that handles Button state changes.
|
||||
*
|
||||
* @protected
|
||||
* @method Phaser.Button.prototype.setState
|
||||
* @param {number} newState - The new State of the Button.
|
||||
*/
|
||||
Phaser.Button.prototype.setState = function (newState) {
|
||||
|
||||
if (newState === 1)
|
||||
{
|
||||
// Over
|
||||
if (this._onOverFrameName != null)
|
||||
{
|
||||
this.frameName = this._onOverFrameName;
|
||||
}
|
||||
else if (this._onOverFrameID != null)
|
||||
{
|
||||
this.frame = this._onOverFrameID;
|
||||
}
|
||||
}
|
||||
else if (newState === 2)
|
||||
{
|
||||
// Out
|
||||
if (this._onOutFrameName != null)
|
||||
{
|
||||
this.frameName = this._onOutFrameName;
|
||||
@@ -957,10 +1024,29 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) {
|
||||
this.frame = this._onOutFrameID;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.onInputUp)
|
||||
else if (newState === 3)
|
||||
{
|
||||
this.onInputUp.dispatch(this, pointer);
|
||||
// Down
|
||||
if (this._onDownFrameName != null)
|
||||
{
|
||||
this.frameName = this._onDownFrameName;
|
||||
}
|
||||
else if (this._onDownFrameID != null)
|
||||
{
|
||||
this.frame = this._onDownFrameID;
|
||||
}
|
||||
}
|
||||
else if (newState === 4)
|
||||
{
|
||||
// Up
|
||||
if (this._onUpFrameName != null)
|
||||
{
|
||||
this.frameName = this._onUpFrameName;
|
||||
}
|
||||
else if (this._onUpFrameID != null)
|
||||
{
|
||||
this.frame = this._onUpFrameID;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -979,13 +1065,13 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) {
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2013 Photon Storm Ltd.
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Wed Feb 05 2014 06:28:24 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user