mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Examples (audio, button,camera), and docs
Created some examples (audio, button,camera), and documented the source code along the way
This commit is contained in:
@@ -3,6 +3,15 @@
|
||||
*
|
||||
* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
|
||||
* The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y
|
||||
*
|
||||
* @class Phaser.Camera
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} game reference to the currently running game.
|
||||
* @param id {number} not being used at the moment, will be when Phaser supports multiple camera
|
||||
* @param x {number} position of the camera on the X axis
|
||||
* @param y {number} position of the camera on the Y axis
|
||||
* @param width {number} the width of the view rectangle
|
||||
* @param height {number} the height of the view rectangle
|
||||
*/
|
||||
|
||||
Phaser.Camera = function (game, id, x, y, width, height) {
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
|
||||
|
||||
* @class Phaser.Camera
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} game reference to the currently running game.
|
||||
* @param width {number} width of the canvas element
|
||||
* @param height {number} height of the canvas element
|
||||
*/
|
||||
Phaser.Stage = function (game, width, height) {
|
||||
|
||||
|
||||
+6
-1
@@ -11,6 +11,10 @@
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
|
||||
* @class World
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} reference to the current game instance.
|
||||
*/
|
||||
Phaser.World = function (game) {
|
||||
|
||||
@@ -91,7 +95,7 @@ Phaser.World.prototype = {
|
||||
|
||||
/**
|
||||
* Updates the size of this world.
|
||||
*
|
||||
* @method setSize
|
||||
* @param width {number} New width of the world.
|
||||
* @param height {number} New height of the world.
|
||||
*/
|
||||
@@ -111,6 +115,7 @@ Phaser.World.prototype = {
|
||||
|
||||
/**
|
||||
* Destroyer of worlds.
|
||||
* @method setSize
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/**
|
||||
* Create a new <code>Button</code> object.
|
||||
* @class Button
|
||||
* @constructor
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param [x] {number} X position of the button.
|
||||
@@ -58,7 +60,15 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
|
||||
Phaser.Button.prototype.constructor = Phaser.Button;
|
||||
|
||||
// Add our own custom methods
|
||||
/**
|
||||
* Used to manually set the frames that will be used for the different states of the button
|
||||
* exactly like setting them in the constructor
|
||||
*
|
||||
* @method setFrames
|
||||
* @param [overFrame] {string|number} 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 [outFrame] {string|number} 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 [downFrame] {string|number} 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.
|
||||
*/
|
||||
|
||||
Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
|
||||
|
||||
+14
-4
@@ -1,7 +1,17 @@
|
||||
/**
|
||||
* The Sound class
|
||||
*
|
||||
* @class Sound
|
||||
* @constructor
|
||||
* @param game {Phaser.Game} reference to the current game instance.
|
||||
* @param key {string} Asset key for the sound.
|
||||
* @param volume {number} default value for the volume.
|
||||
* @param loop {bool} Whether or not the sound will loop.
|
||||
*/
|
||||
Phaser.Sound = function (game, key, volume, loop) {
|
||||
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
|
||||
this.game = game;
|
||||
this.name = '';
|
||||
@@ -187,8 +197,8 @@ Phaser.Sound.prototype = {
|
||||
marker = marker || '';
|
||||
position = position || 0;
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
forceRestart = forceRestart || false;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
if (typeof forceRestart == 'undefined') { forceRestart = false; }
|
||||
|
||||
// console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop);
|
||||
|
||||
@@ -356,7 +366,7 @@ Phaser.Sound.prototype = {
|
||||
marker = marker || '';
|
||||
position = position || 0;
|
||||
volume = volume || 1;
|
||||
loop = loop || false;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
|
||||
this.play(marker, position, volume, loop, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user