8 Commits
Author SHA1 Message Date
Richard Davey 3c5ea01e09 1.0.3 release - fixed Text and Bitmap Fonts, Animation documentation and more examples 2013-09-17 16:50:47 +01:00
Richard Davey f4734b1143 Merge pull request #46 from webeled/master
jsdocs update plus some audio, button and camera examples.
2013-09-16 13:25:17 -07:00
Webeled bb9761aaf4 It loops but still problems on the constructor 2013-09-16 17:40:56 +02:00
Webeled fc584cf6bc Examples (audio, button,camera), and docs
Created some examples (audio, button,camera), and documented the source
code along the way
2013-09-16 16:37:30 +02:00
Richard Davey 17e208a95e 1.0.2 build 2013-09-16 01:53:53 +01:00
Richard Davey e3869ff3ac * Fixed a bug in the AnimationManager where useNumericIndex was always set to true
* Added in lots of Particle examples
* Added in the start of a Breakout game
* Added in the start of a Platformer game
2013-09-16 01:52:15 +01:00
Richard Davey e705509d29 Added lots of particles examples. 2013-09-16 01:08:06 +01:00
Richard Davey 8c9a7c8bc7 Adding more examples in. 2013-09-15 20:45:00 +01:00
60 changed files with 2498 additions and 433 deletions
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

+2 -3
View File
@@ -34,11 +34,10 @@ public game: Phaser.Game;
*/
/**
* My property description. Like other pieces of your comment blocks,
* this can span multiple lines.
* Property description.
*
* @property propertyName
* @public
* @public @private
* @type {Object}
* @default "foo"
*/
+32 -12
View File
@@ -5,7 +5,7 @@ Phaser 1.0
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It supports Canvas and WebGL rendering.
Version: 1.0.1 - Released: September 15th 2013
Version: 1.0.3 - Released: September 17th 2013
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
@@ -34,6 +34,37 @@ Phaser is everything we ever wanted from an HTML5 game framework. It will power
![Blasteroids](http://www.photonstorm.com/wp-content/uploads/2013/04/phaser_blaster.png)
Change Log
----------
Version 1.0.3 (September 17th 2013)
* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function.
* Various fixes to looping parameters in the Sound system.
* Documentation started across most classes. Keep track of progress in the Docs folder.
* Optimised AnimationManager.add so it will only get the required frames rather than all of them and is now faster at parsing the frame data.
* Fixed Phaser.Text and Phaser.BitmapText so they now render correctly and added several Text examples.
Version 1.0.2 (September 16th 2013)
* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation.
* Fixed an issue causing 'explode' particle bursts to ignore the quantity parameter.
* Added 'collideWorldBounds' to Emitter.makeParticles function.
* Added Emitter.angularDrag
* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis.
* Fixed a bug in the AnimationManager where useNumericIndex was always set to true
* Added in lots of Particle examples
* Added in the start of a Breakout game
* Added in the start of a Platformer game
Version 1.0.1 (September 15th 2013)
* Added checks into every Group function to ensure that the Group has children before running them.
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation.
* Fixed the license in package.json
* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles.
Requirements
------------
@@ -113,17 +144,6 @@ Although Phaser 1.0 is a brand new release it is born from years of experience b
![Phaser Particles](http://www.photonstorm.com/wp-content/uploads/2013/04/phaser_particles.png)
Change Log
----------
Version 1.0.1
* Added checks into every Group function to ensure that the Group has children before running them.
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation.
* Fixed the license in package.json
* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles.
Known Issues
------------
+1 -1
View File
File diff suppressed because one or more lines are too long
+48 -14
View File
@@ -1,7 +1,7 @@
/**
* Phaser - http://www.phaser.io
*
* v1.0.1 - Built at: Sun, 15 Sep 2013 02:56:00 +0000
* v1.0.1 - Built at: Mon, 16 Sep 2013 00:53:02 +0000
*
* @author Richard Davey http://www.photonstorm.com @photonstorm
*
@@ -34,7 +34,7 @@ var PIXI = PIXI || {};
*/
var Phaser = Phaser || {
VERSION: '1.0.1',
VERSION: '1.0.2',
GAMES: [],
AUTO: 0,
CANVAS: 1,
@@ -20467,8 +20467,9 @@ Phaser.AnimationManager.prototype = {
frames = frames || null;
frameRate = frameRate || 60;
loop = loop || false;
useNumericIndex = useNumericIndex || true;
if (typeof loop == 'undefined') { loop = false; }
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
if (this._frameData == null)
{
@@ -20519,6 +20520,8 @@ Phaser.AnimationManager.prototype = {
*/
validateFrames: function (frames, useNumericIndex) {
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
for (var i = 0; i < frames.length; i++)
{
if (useNumericIndex == true)
@@ -20574,21 +20577,23 @@ Phaser.AnimationManager.prototype = {
* Stop animation. If a name is given that specific animation is stopped, otherwise the current one is stopped.
* Current animation will be automatically set to the stopped one.
*/
stop: function (name) {
stop: function (name, resetFrame) {
if (typeof resetFrame == 'undefined') { resetFrame = false; }
if (typeof name == 'string')
{
if (this._anims[name])
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
this.currentAnim.stop(resetFrame);
}
}
else
{
if (this.currentAnim)
{
this.currentAnim.stop();
this.currentAnim.stop(resetFrame);
}
}
@@ -20805,11 +20810,18 @@ Phaser.Animation.prototype = {
/**
* Stop playing animation and set it finished.
*/
stop: function () {
stop: function (resetFrame) {
if (typeof resetFrame == 'undefined') { resetFrame = false; }
this.isPlaying = false;
this.isFinished = true;
if (resetFrame)
{
this.currentFrame = this._frameData.getFrame(this._frames[0]);
}
},
/**
@@ -21431,6 +21443,7 @@ Phaser.Animation.Parser = {
for (var key in frames)
{
console.log(key);
var uuid = game.rnd.uuid();
newFrame = data.addFrame(new Phaser.Animation.Frame(
@@ -26455,6 +26468,11 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
*/
this.particleDrag = new Phaser.Point();
/**
* The angular drag component of particles launched from the emitter if they are rotating.
*/
this.angularDrag = 0;
/**
* How often a particle is emitted in ms (if emitter is started with Explode == false).
*/
@@ -26472,9 +26490,9 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
this.lifespan = 2000;
/**
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
* How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
*/
this.bounce = 0;
this.bounce = new Phaser.Point();
/**
* Internal helper for deciding how many particles to launch.
@@ -26573,7 +26591,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
*
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
*/
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide) {
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {
if (typeof frames == 'undefined')
{
@@ -26581,7 +26599,12 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
}
quantity = quantity || this.maxParticles;
collide = collide || 0;
collide = collide || 0;
if (typeof collideWorldBounds == 'undefined')
{
collideWorldBounds = false;
}
var particle;
var i = 0;
@@ -26619,6 +26642,8 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
particle.body.allowCollision.none = true;
}
particle.body.collideWorldBounds = collideWorldBounds;
particle.exists = false;
particle.visible = false;
@@ -26686,7 +26711,15 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
this._explode = explode;
this.lifespan = lifespan;
this.frequency = frequency;
this._quantity += quantity;
if (explode)
{
this._quantity = quantity;
}
else
{
this._quantity += quantity;
}
this._counter = 0;
this._timer = this.game.time.now + frequency;
@@ -26716,7 +26749,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.lifespan = this.lifespan;
particle.body.bounce.setTo(this.bounce, this.bounce);
particle.body.bounce.setTo(this.bounce.x, this.bounce.y);
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
{
@@ -26755,6 +26788,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.body.drag.x = this.particleDrag.x;
particle.body.drag.y = this.particleDrag.y;
particle.body.angularDrag = this.angularDrag;
}
+43
View File
@@ -0,0 +1,43 @@
<?php
$title = "Sprite Sheet";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
var mummy = game.add.sprite(300, 200, 'mummy');
// Here we add a new animation called 'walk'
// Because we didn't give any other parameters it's going to make an animation from all available frames in the 'mummy' sprite sheet
mummy.animations.add('walk');
// And this starts the animation playing by using its key ("walk")
// 30 is the frame rate (30fps)
// true means it will loop when it finishes
mummy.animations.play('walk', 30, true);
}
})();
</script>
<?php
require('../foot.php');
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$title = "Animation from a Texture Atlas";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
function create() {
// This sprite is using a texture atlas for all of its animation data
var bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
})();
</script>
<?php
require('../foot.php');
?>
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
+64 -64
View File
@@ -5,70 +5,70 @@
</tileset>
<layer name="Tile Layer 1" width="64" height="64">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,9,0,0,0,0,52,19,
19,36,19,19,21,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,35,19,36,19,19,38,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,19,41,0,0,0,0,0,25,
53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,52,53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,57,53,60,0,0,0,0,0,18,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,6,5,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,54,55,57,58,0,0,0,0,0,0,8,9,0,0,0,0,0,0,0,0,0,42,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,19,41,0,0,0,0,0,0,0,50,8,19,
6,2,3,6,7,0,0,0,0,0,0,13,14,0,0,0,0,0,0,13,14,0,0,0,0,1,34,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,57,53,60,0,0,0,0,0,0,1,67,19,19,
36,19,22,23,24,0,0,0,0,0,1,30,31,9,0,0,0,0,1,30,31,9,0,0,0,59,55,57,60,0,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,19,19,
19,19,39,40,41,0,0,0,0,0,25,19,19,26,0,0,0,0,25,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,64,65,9,0,0,0,0,0,46,7,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,19,19,19,
20,54,55,57,60,0,0,0,0,0,59,57,53,60,0,0,0,0,59,57,53,60,0,0,0,0,0,0,0,0,0,0,0,0,59,57,56,60,0,0,0,0,1,5,19,7,0,0,0,0,0,0,0,0,0,0,0,0,52,57,54,53,19,19,
24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,53,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,19,
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,58,0,0,0,0,14,14,14,0,0,0,0,0,0,0,0,0,0,35,
43,0,0,0,0,0,0,47,48,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,31,31,31,9,17,0,0,0,0,0,0,0,0,18,
19,9,0,0,0,1,4,64,65,2,3,4,5,2,64,65,3,6,7,0,1,2,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,19,36,57,60,0,0,0,0,0,0,0,0,25,
19,26,0,0,0,18,19,19,19,19,19,37,19,19,36,19,22,23,24,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,1,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,60,0,0,0,0,0,0,0,0,0,0,42,
19,43,0,0,0,25,19,19,19,19,36,19,19,19,19,19,39,40,41,0,18,19,19,19,9,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
19,41,0,0,0,42,19,19,19,53,54,53,53,55,53,54,55,57,60,0,59,56,56,56,60,0,0,0,0,0,0,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19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
19,19,3,66,67,68,2,64,65,6,2,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
19,19,20,19,19,19,19,19,37,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,19,
37,19,19,19,19,19,20,19,19,38,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
19,19,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
19,38,19,19,19,19,19,19,19,19,19,19,19,19,57,57,57,57,57,57,57,57,57,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
19,19,19,19,19,19,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
19,19,19,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,
19,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,0,0,0,0,0,19,
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,19,19,19,19,0,0,0,0,19,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,19,19,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,
19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,
19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,19,19,19,0,19,19,19,19,19,19,19,19,19,19,
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,19,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19
</data>
</layer>
</map>
+236
View File
@@ -0,0 +1,236 @@
{"frames": [
{
"filename": "ball_1.png",
"frame": {"x":218,"y":38,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "ball_2.png",
"frame": {"x":218,"y":20,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "ball_3.png",
"frame": {"x":218,"y":2,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "ball_4.png",
"frame": {"x":200,"y":38,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "ball_5.png",
"frame": {"x":200,"y":20,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "brick_1_1.png",
"frame": {"x":98,"y":21,"w":32,"h":17},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":17},
"sourceSize": {"w":32,"h":17}
},
{
"filename": "brick_1_2.png",
"frame": {"x":98,"y":2,"w":32,"h":17},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":17},
"sourceSize": {"w":32,"h":17}
},
{
"filename": "brick_1_3.png",
"frame": {"x":270,"y":17,"w":30,"h":13},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":1,"w":30,"h":13},
"sourceSize": {"w":32,"h":17}
},
{
"filename": "brick_1_4.png",
"frame": {"x":54,"y":52,"w":24,"h":9},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":4,"w":24,"h":9},
"sourceSize": {"w":32,"h":17}
},
{
"filename": "brick_2_1.png",
"frame": {"x":236,"y":19,"w":32,"h":15},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":15},
"sourceSize": {"w":32,"h":15}
},
{
"filename": "brick_2_2.png",
"frame": {"x":236,"y":2,"w":32,"h":15},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":15},
"sourceSize": {"w":32,"h":15}
},
{
"filename": "brick_2_3.png",
"frame": {"x":270,"y":2,"w":30,"h":13},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":0,"w":30,"h":13},
"sourceSize": {"w":32,"h":15}
},
{
"filename": "brick_2_4.png",
"frame": {"x":236,"y":50,"w":24,"h":11},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":3,"w":24,"h":11},
"sourceSize": {"w":32,"h":15}
},
{
"filename": "brick_3_1.png",
"frame": {"x":166,"y":20,"w":32,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_3_2.png",
"frame": {"x":166,"y":2,"w":32,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_3_3.png",
"frame": {"x":236,"y":36,"w":30,"h":12},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":2,"w":30,"h":12},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_3_4.png",
"frame": {"x":28,"y":52,"w":24,"h":10},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":3,"w":24,"h":10},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "one.png",
"frame": {"x":66,"y":2,"w":30,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":16,"w":30,"h":48},
"sourceSize": {"w":32,"h":64}
},
{
"filename": "paddle_big.png",
"frame": {"x":98,"y":40,"w":48,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":16},
"sourceSize": {"w":48,"h":16}
},
{
"filename": "paddle_small.png",
"frame": {"x":148,"y":38,"w":32,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "power_down.png",
"frame": {"x":200,"y":2,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "power_up.png",
"frame": {"x":182,"y":38,"w":16,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":16,"h":16},
"sourceSize": {"w":16,"h":16}
},
{
"filename": "brick_4_1.png",
"frame": {"x":132,"y":20,"w":32,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_4_2.png",
"frame": {"x":132,"y":2,"w":32,"h":16},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":16},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_4_3.png",
"frame": {"x":270,"y":32,"w":30,"h":12},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":2,"w":30,"h":12},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "brick_4_4.png",
"frame": {"x":2,"y":52,"w":24,"h":10},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":3,"w":24,"h":10},
"sourceSize": {"w":32,"h":16}
},
{
"filename": "three.png",
"frame": {"x":34,"y":2,"w":30,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":0,"w":30,"h":48},
"sourceSize": {"w":32,"h":48}
},
{
"filename": "two.png",
"frame": {"x":2,"y":2,"w":30,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":16,"w":30,"h":48},
"sourceSize": {"w":32,"h":64}
}],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "breakout.png",
"format": "RGBA8888",
"size": {"w":302,"h":64},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:c510ff2f709e8d175b059cd1cbe64773$"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+46
View File
@@ -0,0 +1,46 @@
<?php
$title = "Using samples and looping";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create});
function preload() {
game.load.image('spyro', 'assets/pics/spyro.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('squit', ['assets/audio/SoundEffects/squit.mp3', 'assets/audio/SoundEffects/squit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#255d3b';
music = game.add.audio('squit',1,true);
music.play('',0,1,true);
s = game.add.sprite(game.world.centerX, game.world.centerY, 'spyro');
s.anchor.setTo(0.5, 0.5);
}
})();
</script>
<?php
require('../foot.php');
?>
+48
View File
@@ -0,0 +1,48 @@
<?php
$title = "Clicking on a button ";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button,
background;
function create() {
game.stage.backgroundColor = '#182d3b';
background=game.add.tileSprite(0, 0, 800, 600, 'background');
button = game.add.button(game.world.centerX, 400, 'button', actionOnClick, this, 2, 1, 0);
}
function actionOnClick () {
background.visible=!background.visible;
}
})();
</script>
<?php
require('../foot.php');
?>
+55
View File
@@ -0,0 +1,55 @@
<?php
$title = "Programmatically changing the frames";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/number-buttons-90x90.png', 90,90);
game.load.image('background','assets/misc/starfield.jpg');
}
var button,
background;
function create() {
//setting the background colour
game.stage.backgroundColor = '#182d3b';
// the numbers given in parameters are the indexes of the frames, in this order :
// over,out,down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 1, 0, 2);
//setting the anchor to the center
button.anchor.setTo(0.5,0.5);
}
function actionOnClick () {
//manually changing the frames of the button, i.e, how it will look when you play with it
button.setFrames(4,3,5);
console.log('You clicked on the button');
}
})();
</script>
<?php
require('../foot.php');
?>
+56
View File
@@ -0,0 +1,56 @@
<?php
$title = "Rotating a button";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create,update : update });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button,
background;
function create() {
game.stage.backgroundColor = '#cccccc';
// the numbers given in parameters are the indexes of the frames, in this order :
// over,out,down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 1, 0, 2);
//set the anchor of the sprite in the center, otherwise it would rotate around the top-left corner
button.anchor.setTo(0.5,0.5);
}
function actionOnClick () {
alert("Though I'm turning around, you can still click on me");
}
function update () {
button.angle+=1;
}
})();
</script>
<?php
require('../foot.php');
?>
+76
View File
@@ -0,0 +1,76 @@
<?php
$title = "Following the player";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update });
var baddie,
keys=Phaser.Keyboard;
function preload() {
game.load.image('background','assets/misc/starfield.jpg');
game.load.image('ufo','assets/sprites/ufo.png');
game.load.image('baddie','assets/sprites/space-baddie.png');
}
function create() {
game.add.tileSprite(0, 0, 2000, 2000, 'background');
game.world.setSize(1400,1400);
for(var i=0,nb=10;i<nb;i++){
game.add.sprite(game.world.randomX,game.world.randomY,'ufo');
}
baddie=game.add.sprite(150,320,'baddie');
game.camera.follow(baddie);
}
function update() {
baddie.body.velocity.x=baddie.body.velocity.y=0;
if(game.input.keyboard.isDown(keys.LEFT) && !game.input.keyboard.isDown(keys.RIGHT)){
baddie.body.velocity.x=-155;
}
else if(game.input.keyboard.isDown(keys.RIGHT) && !game.input.keyboard.isDown(keys.LEFT)){
baddie.body.velocity.x=155;
}
else if(game.input.keyboard.isDown(keys.UP) && !game.input.keyboard.isDown(keys.DOWN)){
baddie.angle=90;
baddie.body.velocity.y=-155;
}
else if(game.input.keyboard.isDown(keys.DOWN) && !game.input.keyboard.isDown(keys.UP)){
baddie.angle=90;
baddie.body.velocity.y=155;
}
}
})();
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,60 @@
<?php
$title = "Moving the game camera with the keyboard";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
}
function create() {
//setting the size of the game world larger than the tilemap's size
game.world.setSize(2000,2000);
// game.camera.width=150;
// game.camera.height=150;
game.stage.backgroundColor = '#255d3b';
// adding the tilemap
game.add.tilemap(0, 168, 'snes');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 8;
}
}
})();
</script>
<?php
require('../foot.php');
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
$title = "Modified bounding box";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var sprite1;
var sprite2;
function create() {
game.stage.backgroundColor = '#2d2d2d';
sprite1 = game.add.sprite(50, 200, 'atari');
sprite1.name = 'atari';
sprite1.body.velocity.x = 100;
// This adjusts the collision body size.
// 100x100 is the new width/height.
// See the offset bounding box for another example.
sprite1.body.setSize(100, 100, 0, 0);
sprite2 = game.add.sprite(700, 220, 'mushroom');
sprite2.name = 'mushroom';
sprite2.body.velocity.x = -100;
}
function update() {
// object1, object2, collideCallback, processCallback, callbackContext
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
game.debug.renderRectangle(sprite1.body);
game.debug.renderRectangle(sprite2.body);
}
})();
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,66 @@
<?php
$title = "Larger bounding box";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var sprite1;
var sprite2;
function create() {
game.stage.backgroundColor = '#2d2d2d';
sprite1 = game.add.sprite(50, 200, 'atari');
sprite1.name = 'atari';
sprite1.body.velocity.x = 100;
// In this example the new collision box is much larger than the original sprite
sprite1.body.setSize(400, 50, -100, 20);
sprite2 = game.add.sprite(700, 220, 'mushroom');
sprite2.name = 'mushroom';
sprite2.body.velocity.x = -100;
}
function update() {
// object1, object2, collideCallback, processCallback, callbackContext
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
game.debug.renderRectangle(sprite1.body);
game.debug.renderRectangle(sprite2.body);
}
})();
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,69 @@
<?php
$title = "Offset bounding box";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var sprite1;
var sprite2;
function create() {
game.stage.backgroundColor = '#2d2d2d';
sprite1 = game.add.sprite(50, 200, 'atari');
sprite1.name = 'atari';
sprite1.body.velocity.x = 100;
// This adjusts the collision body size.
// 100x50 is the new width/height.
// 50, 25 is the X and Y offset of the newly sized box.
// In this case the box is 50px in and 25px down.
sprite1.body.setSize(100, 50, 50, 25);
sprite2 = game.add.sprite(700, 220, 'mushroom');
sprite2.name = 'mushroom';
sprite2.body.velocity.x = -100;
}
function update() {
// object1, object2, collideCallback, processCallback, callbackContext
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
game.debug.renderRectangle(sprite1.body);
game.debug.renderRectangle(sprite2.body);
}
})();
</script>
<?php
require('../foot.php');
?>
+44
View File
@@ -0,0 +1,44 @@
<?php
$title = "Canvas Smoothing";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('boss', 'assets/misc/boss1.png');
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
}
var boss,
button;
function create() {
// For browsers that support it, this keeps our pixel art looking crisp
//Phaser.Canvas.setSmoothingEnabled(game.stage.canvas.context, false);
boss = game.add.sprite(game.world.centerX, game.world.centerY, 'boss');
boss.anchor.setTo(0.5, 0.5);
// Zoom in each time we press it
button = game.add.button(32, 32, 'button', clickedIt, this, 2, 1, 0);
}
function clickedIt() {
boss.scale.x += 0.5;
boss.scale.y += 0.5;
}
})();
</script>
<?php
require('../foot.php');
?>
+91
View File
@@ -0,0 +1,91 @@
<?php
$title = "Breakout";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.atlas('breakout', 'assets/sprites/breakout.png', 'assets/sprites/breakout.json');
}
var ball;
var paddle;
var bricks;
var ballOnPaddle = true;
function create() {
var brick;
bricks = game.add.group();
for (var y = 0; y < 4; y++)
{
for (var x = 0; x < 15; x++)
{
brick = bricks.create(120 + (x * 36), 100 + (y * 52), 'breakout', 'brick_' + (y+1) + '_1.png');
brick.body.bounce.setTo(1, 1);
brick.body.immovable = true;
}
}
ball = game.add.sprite(game.world.centerX, 534, 'breakout', 'ball_1.png');
ball.body.collideWorldBounds = true;
ball.body.bounce.setTo(1, 1);
ball.animations.add('spin', [ 'ball_1.png', 'ball_2.png', 'ball_3.png', 'ball_4.png', 'ball_5.png' ], 50, true, false);
paddle = game.add.sprite(game.world.centerX, 550, 'breakout', 'paddle_big.png');
paddle.body.collideWorldBounds = true;
paddle.body.bounce.setTo(1, 1);
paddle.body.immovable = true;
game.input.onDown.add(releaseBall, this);
}
function update () {
paddle.x = game.input.x;
if (ballOnPaddle)
{
ball.x = paddle.x + 16;
}
else
{
game.physics.collide(paddle, ball);
game.physics.collide(ball, bricks, ballHitBrick, null, this);
}
}
function releaseBall () {
ballOnPaddle = false;
ball.body.velocity.y = -300;
ball.body.velocity.x = -75;
ball.animations.play('spin');
}
function ballHitBrick (_ball, _brick) {
_brick.kill();
}
function render () {
}
})();
</script>
<?php
require('../foot.php');
?>
+3 -2
View File
@@ -34,13 +34,14 @@
bg.scrollFactor.setTo(0, 0);
map = game.add.tilemap(0, 0, 'level1');
map.setCollisionRange(1, 20, true, true, true, true);
map.setCollisionRange(1, 12, true, true, true, true);
map.setCollisionRange(18, 47, true, true, true, true);
map.setCollisionRange(53, 69, true, true, true, true);
player = game.add.sprite(32, 32, 'dude');
player.body.bounce.y = 0.2;
player.body.collideWorldBounds = true;
player.body.gravity.y = 10;
player.animations.add('left', [0, 1, 2, 3], 10, true);
player.animations.add('turn', [4], 20, true);
@@ -55,7 +56,7 @@
game.physics.collide(player, map);
player.body.velocity.x = 0;
player.body.acceleration.y = 500;
// player.body.acceleration.y = 500;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
+13 -2
View File
@@ -50,6 +50,7 @@
<script src="../src/core/Group.js"></script>
<script src="../src/core/World.js"></script>
<script src="../src/core/Game.js"></script>
<script src="../src/input/Input.js"></script>
<script src="../src/input/Keyboard.js"></script>
<script src="../src/input/Mouse.js"></script>
@@ -57,41 +58,51 @@
<script src="../src/input/Pointer.js"></script>
<script src="../src/input/Touch.js"></script>
<script src="../src/input/InputHandler.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/gameobjects/Events.js"></script>
<script src="../src/gameobjects/GameObjectFactory.js"></script>
<script src="../src/gameobjects/Sprite.js"></script>
<script src="../src/gameobjects/TileSprite.js"></script>
<script src="../src/gameobjects/Text.js"></script>
<script src="../src/gameobjects/BitmapText.js"></script>
<script src="../src/gameobjects/Button.js"></script>
<script src="../src/gameobjects/Graphics.js"></script>
<script src="../src/gameobjects/RenderTexture.js"></script>
<script src="../src/gameobjects/BitmapText.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/system/StageScaleMode.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/math/QuadTree.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Rectangle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/AnimationManager.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/loader/Parser.js"></script>
<script src="../src/sound/Sound.js"></script>
<script src="../src/sound/SoundManager.js"></script>
<script src="../src/utils/Debug.js"></script>
<script src="../src/utils/Color.js"></script>
+52
View File
@@ -0,0 +1,52 @@
<?php
$title = "Click to Burst";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
var emitter;
function preload() {
game.load.image('diamond', 'assets/sprites/diamond.png');
}
function create() {
game.stage.backgroundColor = 0x337799;
emitter = game.add.emitter(0, 0, 200);
emitter.makeParticles('diamond');
emitter.gravity = 10;
game.input.onDown.add(particleBurst, this);
}
function particleBurst() {
// Position the emitter where the mouse/touch event was
emitter.x = game.input.x;
emitter.y = game.input.y;
// The first parameter sets the effect to "explode" which means all particles are emitted at once
// The second gives each particle a 2000ms lifespan
// The third is ignored when using burst/explode mode
// The final parameter (10) is how many particles will be emitted in this single burst
emitter.start(true, 2000, null, 10);
}
})();
</script>
<?php
require('../foot.php');
?>
+48
View File
@@ -0,0 +1,48 @@
<?php
$title = "Collision";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update });
var emitter;
function preload() {
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
}
function create() {
emitter = game.add.emitter(game.world.centerX, game.world.centerY, 250);
emitter.makeParticles('veggies', [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], 200, true, true);
emitter.minParticleSpeed.setTo(-200, -300);
emitter.maxParticleSpeed.setTo(200, -400);
emitter.gravity = 8;
emitter.bounce.setTo(0.5, 0.5);
emitter.particleDrag.x = 10;
emitter.angularDrag = 30;
emitter.start(false, 8000, 400);
}
function update() {
game.physics.collide(emitter, emitter);
}
})();
</script>
<?php
require('../foot.php');
?>
+77
View File
@@ -0,0 +1,77 @@
<?php
$title = "Diamond Burst";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
var p;
var p2;
function preload() {
// game.load.image('carrot', 'assets/sprites/carrot.png');
// game.load.image('star', 'assets/misc/star_particle.png');
game.load.image('diamond', 'assets/sprites/diamond.png');
// game.load.image('dude', 'assets/sprites/phaser-dude.png');
// game.load.image('coke', 'assets/sprites/cokecan.png');
// game.load.atlasJSONHash('pixies', 'assets/sprites/pixi_monsters.png', 'assets/sprites/pixi_monsters.json');
// game.load.spritesheet('balls', 'assets/sprites/balls.png', 17, 17);
}
function create() {
game.stage.backgroundColor = 0x337799;
p = game.add.emitter(game.world.centerX, 200, 200);
// p.width = 200;
// p.height = 200;
// keys, frames, quantity, collide
p.makeParticles('diamond');
// p.makeParticles(['diamond', 'carrot', 'star']);
// p.makeParticles('balls', [0,1,2,3,4,5]);
// p.makeParticles('pixies', [0,1,2,3]);
// p.minParticleScale = 0.1;
// p.maxParticleScale = 0.5;
// Steady constant stream at 250ms delay and 10 seconds lifespan
// p.start(false, 10000, 250, 100);
// p.start(true, 10000);
// explode, lifespan, frequency, quantity
// p.minParticleSpeed.setTo(-100, -100);
// p.maxParticleSpeed.setTo(100, -200);
// p.gravity = 10;
// p.start(false, 3000, 10);
p.start(false, 5000, 20);
// game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Quadratic.InOut, true, 0, 1000, true);
}
function update() {
// p.y = game.math.min(100, game.input.y);
}
function render() {
}
})();
</script>
<?php
require('../foot.php');
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
$title = "No Rotation";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('alien', 'assets/sprites/space-baddie.png');
}
function create() {
var emitter = game.add.emitter(game.world.centerX, game.world.centerY, 250);
emitter.makeParticles('alien');
emitter.minParticleSpeed.setTo(-300, -300);
emitter.maxParticleSpeed.setTo(300, 300);
// By setting the min and max rotation to zero, you disable rotation on the particles fully
emitter.minRotation = 0;
emitter.maxRotation = 0;
emitter.start(false, 4000, 15);
}
})();
</script>
<?php
require('../foot.php');
?>
+46
View File
@@ -0,0 +1,46 @@
<?php
$title = "Random Sprite";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
var emitter;
function preload() {
game.load.image('carrot', 'assets/sprites/carrot.png');
game.load.image('star', 'assets/misc/star_particle.png');
game.load.image('diamond', 'assets/sprites/diamond.png');
}
function create() {
game.stage.backgroundColor = 0x337799;
emitter = game.add.emitter(game.world.centerX, 200, 200);
// Here we're passing an array of image keys. It will pick one at random when emitting a new particle.
emitter.makeParticles(['diamond', 'carrot', 'star']);
emitter.start(false, 5000, 20);
}
function update() {
}
function render() {
}
})();
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,51 @@
<?php
$title = "When Particles Collide";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update });
var leftEmitter;
var rightEmitter;
function preload() {
game.load.image('ball1', 'assets/sprites/red_ball.png');
game.load.image('ball2', 'assets/sprites/blue_ball.png');
}
function create() {
leftEmitter = game.add.emitter(50, game.world.centerY - 200);
leftEmitter.bounce.setTo(0.5, 0.5);
leftEmitter.setXSpeed(100, 200);
leftEmitter.setYSpeed(-50, 50);
leftEmitter.makeParticles('ball1', 0, 250, 1, true);
rightEmitter = game.add.emitter(game.world.width - 50, game.world.centerY - 200);
rightEmitter.bounce.setTo(0.5, 0.5);
rightEmitter.setXSpeed(-100, -200);
rightEmitter.setYSpeed(-50, 50);
rightEmitter.makeParticles('ball2', 0, 250, 1, true);
// explode, lifespan, frequency, quantity
leftEmitter.start(false, 5000, 20);
rightEmitter.start(false, 5000, 20);
}
function update() {
game.physics.collide(leftEmitter, rightEmitter);
}
})();
</script>
<?php
require('../foot.php');
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
$title = "Zero Gravity";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.spritesheet('balls', 'assets/sprites/balls.png', 17, 17);
}
function create() {
var emitter = game.add.emitter(game.world.centerX, game.world.centerY, 250);
emitter.makeParticles('balls', [0, 1, 2, 3, 4, 5]);
emitter.minParticleSpeed.setTo(-400, -400);
emitter.maxParticleSpeed.setTo(400, 400);
emitter.gravity = 0;
emitter.start(false, 4000, 15);
}
})();
</script>
<?php
require('../foot.php');
?>
-2
View File
@@ -17,8 +17,6 @@
function create() {
// game.world._stage.backgroundColorString = '#182d3b';
s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot');
// s.anchor.setTo(0.5, 0.5);
s.scale.setTo(2, 2);
+29
View File
@@ -0,0 +1,29 @@
<?php
$title = "Bitmap Fonts ahoy";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml');
}
function create() {
game.add.bitmapText(200, 100, 'Phaser & Pixi\nrocking!', { font: '64px Desyrel', align: 'center' });
}
})();
</script>
<?php
require('../foot.php');
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
$title = "Hello Arial";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
function create() {
var text = "- phaser -\nwith a sprinkle of\npixi dust";
var style = { font: "65px Arial", fill: "#ff0044", align: "center" };
var t = game.add.text(game.world.centerX, game.world.centerY, text, style);
t.anchor.setTo(0.5, 0.5);
}
})();
</script>
<?php
require('../foot.php');
?>
+78
View File
@@ -0,0 +1,78 @@
<?php
$title = "Kern of Duty";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var content = [
" ",
"photon storm presents",
"a phaser production",
" ",
"Kern of Duty",
" ",
"directed by rich davey",
"rendering by mat groves",
" ",
"03:45, November 4th, 2014",
"somewhere in the north pacific",
"mission control bravo ...",
];
var t = 0;
var s;
var index = 0;
var line = '';
function preload() {
game.load.image('cod', 'assets/pics/cod.jpg');
}
function create() {
game.add.sprite(0, 0, 'cod');
var style = { font: "30pt Courier", fill: "#19cb65", stroke: "#119f4e", strokeThickness: 2 };
s = game.add.text(32, 380, '', style);
t = game.time.now + 80;
}
function update() {
if (game.time.now > t && index < content.length)
{
// get the next character in the line
if (line.length < content[index].length)
{
line = content[index].substr(0, line.length + 1);
s.setText(line);
t = game.time.now + 80;
}
else
{
t = game.time.now + 2000;
if (index < content.length)
{
index++;
line = '';
}
}
}
}
})();
</script>
<?php
require('../foot.php');
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
$title = "Text Stroke";
require('../head.php');
?>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create, update: update });
var s;
function create() {
var text = "--- phaser ---\nwith a sprinkle of\npixi dust";
var style = { font: "bold 40pt Arial", fill: "#ffffff", align: "center", stroke: "#258acc", strokeThickness: 8 };
s = game.add.text(game.world.centerX, game.world.centerY, text, style);
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.angle += 1;
}
})();
</script>
<?php
require('../foot.php');
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

+1 -1
View File
@@ -3,7 +3,7 @@
*/
var Phaser = Phaser || {
VERSION: '1.0.1',
VERSION: '1.0.3',
GAMES: [],
AUTO: 0,
CANVAS: 1,
+157 -36
View File
@@ -1,43 +1,126 @@
/**
* Animation
*
* An Animation instance contains a single animation and the controls to play it.
* It is created by the AnimationManager and belongs to Game Objects such as Sprite.
*
* @package Phaser.Animation
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
*
* @param parent {Sprite} Owner sprite of this animation.
* @param frameData {FrameData} The FrameData object contains animation data.
* @param name {string} Unique name of this animation.
* @param frames {number[]/string[]} An array of numbers or strings indicating what frames to play in what order.
* @param delay {number} Time between frames in ms.
* @param looped {bool} Whether or not the animation is looped or just plays once.
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Animation
*/
Phaser.Animation = function (game, parent, frameData, name, frames, delay, looped) {
/**
* An Animation instance contains a single animation and the controls to play it.
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
*
* @class Animation
* @constructor
* @param {Phaser.Game} game A reference to the currently running game.
* @param {Phaser.Sprite} parent A reference to the owner of this Animation.
* @param {String} name The unique name for this animation, used in playback commands.
* @param {Phaser.Animation.FrameData} frameData The FrameData object that contains all frames used by this Animation.
* @param {Mixed} frames An array of numbers or strings indicating which frames to play in which order.
* @param {Number} delay The time between each frame of the animation, given in ms.
* @param {Boolean} looped Should this animation loop or play through once.
*/
Phaser.Animation = function (game, parent, name, frameData, frames, delay, looped) {
/**
* A reference to the currently running Game.
* @property game
* @public
* @type {Phaser.Game}
*/
this.game = game;
/**
* A reference to the parent Sprite that owns this Animation.
* @property _parent
* @private
* @type {Phaser.Sprite}
*/
this._parent = parent;
/**
* The FrameData the Animation uses.
* @property _frameData
* @private
* @type {Phaser.FrameData}
*/
this._frameData = frameData;
/**
* The user defined name given to this Animation.
* @property name
* @public
* @type {String}
*/
this.name = name;
/**
* @property _frames
* @private
* @type {Object}
*/
this._frames = frames;
this._frameData = frameData;
this.name = name;
/**
* The delay in ms between each frame of the Animation.
* @property delay
* @public
* @type {Number}
*/
this.delay = 1000 / delay;
/**
* The loop state of the Animation.
* @property looped
* @public
* @type {Boolean}
*/
this.looped = looped;
/**
* The finished state of the Animation. Set to true once playback completes, false during playback.
* @property isFinished
* @public
* @type {Boolean}
* default true
*/
this.isFinished = false;
/**
* The playing state of the Animation. Set to false once playback completes, true during playback.
* @property isPlaying
* @public
* @type {Boolean}
* default false
*/
this.isPlaying = false;
/**
* @property _frameIndex
* @private
* @type {Number}
* default 0
*/
this._frameIndex = 0;
/**
* The currently displayed frame of the Animation.
* @property currentFrame
* @public
* @type {Phaser.Animation.Frame}
*/
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
};
Phaser.Animation.prototype = {
/**
* Play this animation.
* @param frameRate {number} FrameRate you want to specify instead of using default.
* @param loop {bool} Whether or not the animation is looped or just plays once.
/**
* Plays this animation.
*
* @method play
* @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
* @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @return {Phaser.Animation} A reference to this Animation instance.
*/
play: function (frameRate, loop) {
@@ -65,14 +148,20 @@ Phaser.Animation.prototype = {
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
this._parent.events.onAnimationStart.dispatch(this._parent, this);
if (this._parent.events)
{
this._parent.events.onAnimationStart.dispatch(this._parent, this);
}
return this;
},
/**
* Play this animation from the first frame.
/**
* Sets this animation back to the first frame and restarts the animation.
*
* @method restart
*/
restart: function () {
@@ -88,18 +177,30 @@ Phaser.Animation.prototype = {
},
/**
* Stop playing animation and set it finished.
/**
* Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.
*
* @method stop
* @param {Boolean} [resetFrame=false] If true after the animation stops the currentFrame value will be set to the first frame in this animation.
*/
stop: function () {
stop: function (resetFrame) {
if (typeof resetFrame === 'undefined') { resetFrame = false; }
this.isPlaying = false;
this.isFinished = true;
if (resetFrame)
{
this.currentFrame = this._frameData.getFrame(this._frames[0]);
}
},
/**
* Update animation frames.
/**
* Updates this animation. Called automatically by the AnimationManager.
*
* @method update
*/
update: function () {
@@ -137,8 +238,10 @@ Phaser.Animation.prototype = {
},
/**
* Clean up animation memory.
/**
* Cleans up this animation ready for deletion. Nulls all values and references.
*
* @method destroy
*/
destroy: function () {
@@ -151,14 +254,20 @@ Phaser.Animation.prototype = {
},
/**
* Animation complete callback method.
/**
* Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.
*
* @method onComplete
*/
onComplete: function () {
this.isPlaying = false;
this.isFinished = true;
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
if (this._parent.events)
{
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
}
}
@@ -166,6 +275,10 @@ Phaser.Animation.prototype = {
Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
/**
* @method frameTotal
* @return {Number} The total number of frames in this animation.
*/
get: function () {
return this._frames.length;
}
@@ -174,6 +287,10 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
Object.defineProperty(Phaser.Animation.prototype, "frame", {
/**
* @method frame
* @return {Animation.Frame} Returns the current frame, or if not set the index of the most recent frame.
*/
get: function () {
if (this.currentFrame !== null)
@@ -187,6 +304,10 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
},
/**
* @method frame
* @return {Number} Sets the current frame to the given frame index and updates the texture cache.
*/
set: function (value) {
this.currentFrame = this._frameData.getFrame(value);
+147 -77
View File
@@ -1,44 +1,89 @@
/**
* AnimationManager
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Animation
*/
/**
* The AnimationManager is used to add, play and update Phaser Animations.
* Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance.
*
* Any Game Object that supports animation contains a single AnimationManager instance. It is used to add,
* play and update Phaser.Animation objects.
*
* @package Phaser.Components.AnimationManager
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @class AnimationManager
* @constructor
* @param {Phaser.Sprite} sprite A reference to the Game Object that owns this AnimationManager.
*/
Phaser.AnimationManager = function (sprite) {
/**
* Data contains animation frames.
* @type {FrameData}
*/
this._frameData = null;
/**
* Keeps track of the current frame of the animation.
*/
this.currentFrame = null;
/**
* A reference to the parent Sprite that owns this AnimationManager.
* @property sprite
* @public
* @type {Phaser.Sprite}
*/
this.sprite = sprite;
/**
* A reference to the currently running Game.
* @property game
* @public
* @type {Phaser.Game}
*/
this.game = sprite.game;
/**
* The currently displayed Frame of animation, if any.
* @property currentFrame
* @public
* @type {Phaser.Animation.Frame}
*/
this.currentFrame = null;
/**
* Should the animation data continue to update even if the Sprite.visible is set to false.
* @property updateIfVisible
* @public
* @type {Boolean}
* @default true
*/
this.updateIfVisible = true;
/**
* A temp. var for holding the currently playing Animations FrameData.
* @property _frameData
* @private
* @type {Phaser.Animation.FrameData}
*/
this._frameData = null;
/**
* An internal object that stores all of the Animation instances.
* @property _anims
* @private
* @type {Object}
*/
this._anims = {};
this.updateIfVisible = true;
/**
* An internal object to help avoid gc.
* @property _outputFrames
* @private
* @type {Object}
*/
this._outputFrames = [];
};
Phaser.AnimationManager.prototype = {
/**
* Load animation frame data.
* @param frameData Data to be loaded.
*/
/**
* Loads FrameData into the internal temporary vars and resets the frame index to zero.
* This is called automatically when a new Sprite is created.
*
* @method loadFrameData
* @private
* @param {Phaser.Animation.FrameData} frameData The FrameData set to load.
*/
loadFrameData: function (frameData) {
this._frameData = frameData;
@@ -47,27 +92,30 @@ Phaser.AnimationManager.prototype = {
},
/**
* Add a new animation.
* @param name {string} What this animation should be called (e.g. "run").
* @param frames {any[]} An array of numbers/strings indicating what frames to play in what order (e.g. [1, 2, 3] or ['run0', 'run1', run2]).
* @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
* @param loop {bool} Whether or not the animation is looped or just plays once.
* @param useNumericIndex {bool} Use number indexes instead of string indexes?
* @return {Animation} The Animation that was created
* Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
* Animations added in this way are played back with the play function.
*
* @method add
* @param {String} name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".
* @param {Array} [frames=null] An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.
* @param {Number} [frameRate=60] The speed at which the animation should play. The speed is given in frames per second.
* @param {Boolean} [loop=false] {bool} Whether or not the animation is looped or just plays once.
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
* @return {Phaser.Animation} The Animation object that was created.
*/
add: function (name, frames, frameRate, loop, useNumericIndex) {
frames = frames || null;
frameRate = frameRate || 60;
loop = loop || false;
useNumericIndex = useNumericIndex || true;
if (this._frameData == null)
{
console.warn('No frameData available for Phaser.Animation ' + name);
console.warn('No FrameData available for Phaser.Animation ' + name);
return;
}
frameRate = frameRate || 60;
if (typeof loop === 'undefined') { loop = false; }
if (typeof useNumericIndex === 'undefined') { useNumericIndex = true; }
// Create the signals the AnimationManager will emit
if (this.sprite.events.onAnimationStart == null)
{
@@ -76,25 +124,11 @@ Phaser.AnimationManager.prototype = {
this.sprite.events.onAnimationLoop = new Phaser.Signal();
}
if (frames == null)
{
frames = this._frameData.getFrameIndexes();
}
else
{
if (this.validateFrames(frames, useNumericIndex) == false)
{
console.warn('Invalid frames given to Phaser.Animation ' + name);
return;
}
}
this._outputFrames.length = 0;
if (useNumericIndex == false)
{
frames = this._frameData.getFrameIndexesByName(frames);
}
this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
this._anims[name] = new Phaser.Animation(this.game, this.sprite, this._frameData, name, frames, frameRate, loop);
this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
this.currentAnim = this._anims[name];
this.currentFrame = this.currentAnim.currentFrame;
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
@@ -104,13 +138,17 @@ Phaser.AnimationManager.prototype = {
},
/**
* Check whether the frames is valid.
* @param frames {any[]} Frames to be validated.
* @param useNumericIndex {bool} Does these frames use number indexes or string indexes?
* @return {bool} True if they're valid, otherwise return false.
* Check whether the frames in the given array are valid and exist.
*
* @method validateFrames
* @param {Array} frames An array of frames to be validated.
* @param {Boolean} [useNumericIndex=true] Validate the frames based on their numeric index (true) or string index (false)
* @return {Boolean} True if all given Frames are valid, otherwise false.
*/
validateFrames: function (frames, useNumericIndex) {
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
for (var i = 0; i < frames.length; i++)
{
if (useNumericIndex == true)
@@ -134,16 +172,17 @@ Phaser.AnimationManager.prototype = {
},
/**
* Play animation with specific name.
* @param name {string} The string name of the animation you want to play.
* @param frameRate {number} FrameRate you want to specify instead of using default.
* @param loop {bool} Whether or not the animation is looped or just plays once.
* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
*
* @method play
* @param {String} name The name of the animation to be played, e.g. "fire", "walk", "jump".
* @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
* @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @return {Phaser.Animation} A reference to playing Animation instance.
*/
play: function (name, frameRate, loop) {
frameRate = frameRate || null;
loop = loop || null;
if (this._anims[name])
{
if (this.currentAnim == this._anims[name])
@@ -163,32 +202,41 @@ Phaser.AnimationManager.prototype = {
},
/**
* Stop animation. If a name is given that specific animation is stopped, otherwise the current one is stopped.
* Current animation will be automatically set to the stopped one.
* Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped.
* The currentAnim property of the AnimationManager is automatically set to the animation given.
*
* @method stop
* @param {String} [name=null] The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.
* @param {Boolean} [resetFrame=false] When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)
*/
stop: function (name) {
stop: function (name, resetFrame) {
if (typeof resetFrame == 'undefined') { resetFrame = false; }
if (typeof name == 'string')
{
if (this._anims[name])
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
this.currentAnim.stop(resetFrame);
}
}
else
{
if (this.currentAnim)
{
this.currentAnim.stop();
this.currentAnim.stop(resetFrame);
}
}
},
/**
* Update animation and parent sprite's bounds.
* Returns true if a new frame has been set, otherwise false.
* The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.
*
* @method update
* @protected
* @return {Boolean} True if a new animation frame has been set, otherwise false.
*/
update: function () {
@@ -208,8 +256,10 @@ Phaser.AnimationManager.prototype = {
},
/**
* Removes all related references
/**
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
*
* @method destroy
*/
destroy: function () {
@@ -225,6 +275,10 @@ Phaser.AnimationManager.prototype = {
Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
/**
* @method frameData
* @return {Phaser.Animation.FrameData} Returns the FrameData of the current animation.
*/
get: function () {
return this._frameData;
}
@@ -233,6 +287,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
/**
* @method frameTotal
* @return {Number} Returns the total number of frames in the loaded FrameData, or -1 if no FrameData is loaded.
*/
get: function () {
if (this._frameData)
@@ -249,6 +307,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
/**
* @method frame
* @return {Number} Returns the index of the current frame.
*/
get: function () {
if (this.currentFrame)
@@ -259,8 +321,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
},
/**
*
* @param value
* @method frame
* @param {Number} value Sets the current frame on the Sprite and updates the texture cache for display.
*/
set: function (value) {
@@ -278,6 +340,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
/**
* @method frameName
* @return {String} Returns the name of the current frame if it has one.
*/
get: function () {
if (this.currentFrame)
@@ -287,6 +353,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
},
/**
* @method frameName
* @param {String} value Sets the current frame on the Sprite and updates the texture cache for display.
*/
set: function (value) {
if (this._frameData && this._frameData.getFrameByName(value))
+137 -77
View File
@@ -1,123 +1,181 @@
/**
* Frame
*
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Animation
*/
/**
* A Frame is a single frame of an animation and is part of a FrameData collection.
*
* @package Phaser.Animation.Frame
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @class Frame
* @constructor
* @param {Number} index The index of this Frame within the FrameData set it is being added to.
* @param {Number} x X position of the frame within the texture image.
* @param {Number} y Y position of the frame within the texture image.
* @param {Number} width Width of the frame within the texture image.
* @param {Number} height Height of the frame within the texture image.
* @param {String} name The name of the frame. In Texture Atlas data this is usually set to the filename.
* @param {String} uuid Internal UUID key.
*/
Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {
/**
* X position within the image to cut from.
* @type {number}
*/
* The index of this Frame within the FrameData set it is being added to.
* @property index
* @public
* @type {Number}
*/
this.index = index;
/**
* X position within the image to cut from.
* @property x
* @public
* @type {Number}
*/
this.x = x;
/**
* Y position within the image to cut from.
* @type {number}
*/
* Y position within the image to cut from.
* @property y
* @public
* @type {Number}
*/
this.y = y;
/**
* Width of the frame.
* @type {number}
*/
* Width of the frame.
* @property width
* @public
* @type {Number}
*/
this.width = width;
/**
* Height of the frame.
* @type {number}
*/
* Height of the frame.
* @property height
* @public
* @type {Number}
*/
this.height = height;
/**
* center X position within the image to cut from.
* @type {number}
*/
this.centerX = Math.floor(width / 2);
/**
* center Y position within the image to cut from.
* @type {number}
*/
this.centerY = Math.floor(height / 2);
/**
* Useful for Sprite Sheets.
* @type {number}
*/
this.index = 0;
/**
* Useful for Texture Atlas files. (is set to the filename value)
*/
* Useful for Texture Atlas files. (is set to the filename value)
* @property name
* @public
* @type {String}
*/
this.name = name;
/**
* A link to the PIXI.TextureCache entry
*/
* A link to the PIXI.TextureCache entry
* @property uuid
* @public
* @type {String}
*/
this.uuid = uuid;
/**
* The distance from the top left to the bottom-right of this Frame.
* @type {number}
*/
* center X position within the image to cut from.
* @property centerX
* @public
* @type {Number}
*/
this.centerX = Math.floor(width / 2);
/**
* center Y position within the image to cut from.
* @property centerY
* @public
* @type {Number}
*/
this.centerY = Math.floor(height / 2);
/**
* The distance from the top left to the bottom-right of this Frame.
* @property distance
* @public
* @type {Number}
*/
this.distance = Phaser.Math.distance(0, 0, width, height);
/**
* Rotated? (not yet implemented)
*/
* Rotated? (not yet implemented)
* @property rotated
* @public
* @type {Boolean}
* @default false
*/
this.rotated = false;
/**
* Either cw or ccw, rotation is always 90 degrees.
*/
* Either cw or ccw, rotation is always 90 degrees.
* @property rotationDirection
* @public
* @type {String}
* @default "cw"
*/
this.rotationDirection = 'cw';
/**
* Was it trimmed when packed?
* @type {bool}
*/
* Was it trimmed when packed?
* @property trimmed
* @public
* @type {Boolean}
*/
this.trimmed = false;
/**
* Width of the original sprite.
* @type {number}
*/
* Width of the original sprite.
* @property sourceSizeW
* @public
* @type {Number}
*/
this.sourceSizeW = width;
/**
* Height of the original sprite.
* @type {number}
*/
* Height of the original sprite.
* @property sourceSizeH
* @public
* @type {Number}
*/
this.sourceSizeH = height;
/**
* X position of the trimmed sprite inside original sprite.
* @type {number}
*/
* X position of the trimmed sprite inside original sprite.
* @property spriteSourceSizeX
* @public
* @type {Number}
* @default 0
*/
this.spriteSourceSizeX = 0;
/**
* Y position of the trimmed sprite inside original sprite.
* @type {number}
*/
* Y position of the trimmed sprite inside original sprite.
* @property spriteSourceSizeY
* @public
* @type {Number}
* @default 0
*/
this.spriteSourceSizeY = 0;
/**
* Width of the trimmed sprite.
* @type {number}
*/
* Width of the trimmed sprite.
* @property spriteSourceSizeW
* @public
* @type {Number}
* @default 0
*/
this.spriteSourceSizeW = 0;
/**
* Height of the trimmed sprite.
* @type {number}
*/
* Height of the trimmed sprite.
* @property spriteSourceSizeH
* @public
* @type {Number}
* @default 0
*/
this.spriteSourceSizeH = 0;
};
@@ -125,14 +183,16 @@ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
Phaser.Animation.Frame.prototype = {
/**
* Set trim of the frame.
* @param trimmed {bool} Whether this frame trimmed or not.
* @param actualWidth {number} Actual width of this frame.
* @param actualHeight {number} Actual height of this frame.
* @param destX {number} Destination x position.
* @param destY {number} Destination y position.
* @param destWidth {number} Destination draw width.
* @param destHeight {number} Destination draw height.
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
*
* @method setTrim
* @param {Boolean} trimmed If this frame was trimmed or not.
* @param {Number} actualWidth The width of the frame before being trimmed.
* @param {Number} actualHeight The height of the frame before being trimmed.
* @param {Number} destX The destination X position of the trimmed frame for display.
* @param {Number} destY The destination Y position of the trimmed frame for display.
* @param {Number} destWidth The destination width of the trimmed frame for display.
* @param {Number} destHeight The destination height of the trimmed frame for display.
*/
setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
+128 -79
View File
@@ -1,37 +1,45 @@
/**
* FrameData
*
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Animation.FrameData
*/
/**
* FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
*
* @package Phaser.Animation.FrameData
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @class FrameData
* @constructor
*/
Phaser.Animation.FrameData = function () {
/**
* Local frame container.
* @type {Phaser.Frame[]}
* @private
*/
* Local array of frames.
* @property _frames
* @private
* @type {Array}
*/
this._frames = [];
/**
* Local frameName<->index container.
* @private
*/
* Local array of frame names for name to index conversions.
* @property _frameNames
* @private
* @type {Array}
*/
this._frameNames = [];
};
Phaser.Animation.FrameData.prototype = {
/**
* Add a new frame.
* @param frame {Frame} The frame you want to add.
* @return {Frame} The frame you just added.
*/
/**
* Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
*
* @method addFrame
* @param {Phaser.Animation.Frame} frame The frame to add to this FrameData set.
* @return {Phaser.Animation.Frame} The frame that was just added.
*/
addFrame: function (frame) {
frame.index = this._frames.length;
@@ -48,9 +56,11 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Get a frame by its index.
* @param index {number} Index of the frame you want to get.
* @return {Frame} The frame you want.
* Get a Frame by its numerical index.
*
* @method getFrame
* @param {Number} index The index of the frame you want to get.
* @return {Phaser.Animation.Frame} The frame, if found.
*/
getFrame: function (index) {
@@ -63,14 +73,16 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Get a frame by its name.
* @param name {string} Name of the frame you want to get.
* @return {Frame} The frame you want.
*/
/**
* Get a Frame by its frame name.
*
* @method getFrameByName
* @param {String} name The name of the frame you want to get.
* @return {Phaser.Animation.Frame} The frame, if found.
*/
getFrameByName: function (name) {
if (this._frameNames[name] !== '')
if (this._frameNames[name] && this._frameNames[name] !== '')
{
return this._frames[this._frameNames[name]];
}
@@ -79,11 +91,13 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Check whether there's a frame with given name.
* @param name {string} Name of the frame you want to check.
* @return {bool} True if frame with given name found, otherwise return false.
*/
/**
* Check if there is a Frame with the given name.
*
* @method checkFrameName
* @param {String} name The name of the frame you want to check.
* @return {Boolean} True if the frame is found, otherwise false.
*/
checkFrameName: function (name) {
if (this._frameNames[name] == null)
@@ -96,11 +110,13 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Get ranges of frames in an array.
* @param start {number} Start index of frames you want.
* @param end {number} End index of frames you want.
* @param [output] {Frame[]} result will be added into this array.
* @return {Frame[]} Ranges of specific frames in an array.
* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
*
* @method getFrameRange
* @param {Number} start The starting frame index.
* @param {Number} end The ending frame index.
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array.
* @return {Array} An array of Frames between the start and end index values, or an empty array if none were found.
*/
getFrameRange: function (start, end, output) {
@@ -116,37 +132,45 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Get all indexes of frames by giving their name.
* @param [output] {number[]} result will be added into this array.
* @return {number[]} Indexes of specific frames in an array.
* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
* The frames are returned in the output array, or if none is provided in a new Array object.
*
* @method getFrames
* @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created.
* @return {Array} An array of all Frames in this FrameData set matching the given names or IDs.
*/
getFrameIndexes: function (output) {
getFrames: function (frames, useNumericIndex, output) {
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
if (typeof output === "undefined") { output = []; }
for (var i = 0; i < this._frames.length; i++)
if (typeof frames === "undefined" || frames.length == 0)
{
output.push(i);
}
return output;
},
/**
* Get the frame indexes by giving the frame names.
* @param [output] {number[]} result will be added into this array.
* @return {number[]} Names of specific frames in an array.
*/
getFrameIndexesByName: function (input) {
var output = [];
for (var i = 0; i < input.length; i++)
{
if (this.getFrameByName(input[i]))
// No input array, so we loop through all frames
for (var i = 0; i < this._frames.length; i++)
{
output.push(this.getFrameByName(input[i]).index);
// We only need the indexes
output.push(this._frames[i]);
}
}
else
{
// Input array given, loop through that instead
for (var i = 0, len = frames.length; i < len; i++)
{
// Does the input array contain names or indexes?
if (useNumericIndex)
{
// The actual frame
output.push(this.getFrame(input[i]));
}
else
{
// The actual frame
output.push(this.getFrameByName(input[i]));
}
}
}
@@ -154,35 +178,60 @@ Phaser.Animation.FrameData.prototype = {
},
/**
* Get all frames in this frame data.
* @return {Frame[]} All the frames in an array.
*/
getAllFrames: function () {
return this._frames;
},
/**
* Returns all of the Frame indexes in this FrameData set.
* The frames indexes are returned in the output array, or if none is provided in a new Array object.
*
* @method getFrameIndexes
* @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created.
* @return {Array} An array of all Frame indexes matching the given names or IDs.
*/
getFrameIndexes: function (input, useNumericIndex, output) {
/**
* Get All frames with specific ranges.
* @param range {number[]} Ranges in an array.
* @return {Frame[]} All frames in an array.
*/
getFrames: function (range) {
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
if (typeof output === "undefined") { output = []; }
var output = [];
for (var i = 0; i < range.length; i++)
if (typeof frames === "undefined" || frames.length == 0)
{
output.push(this._frames[i]);
// No input array, so we loop through all frames
for (var i = 0, len = this._frames.length; i < len; i++)
{
output.push(this._frames[i].index);
}
}
else
{
// Input array given, loop through that instead
for (var i = 0, len = input.length; i < len; i++)
{
// Does the input array contain names or indexes?
if (useNumericIndex)
{
output.push(input[i].index);
}
else
{
output.push(this.getFrameByName(input[i]).index);
}
}
}
return output;
}
};
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
/**
* Returns the total number of frames in this FrameData set.
*
* @method total
* @return {Number} The total number of frames in this FrameData set.
*/
get: function () {
return this._frames.length;
}
+44 -24
View File
@@ -1,23 +1,25 @@
/**
* Animation Parser
*
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
*
* @package Phaser.Animation.Parser
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Animation
*/
Phaser.Animation.Parser = {
/**
* Parse a sprite sheet from asset data.
* @param key {string} Asset key for the sprite sheet data.
* @param frameWidth {number} Width of animation frame.
* @param frameHeight {number} Height of animation frame.
* @param frameMax {number} Number of animation frames.
* @return {FrameData} Generated FrameData object.
*/
/**
* Parse a Sprite Sheet and extract the animation frame data from it.
*
* @method spriteSheet
* @param {Phaser.Game} game A reference to the currently running game.
* @param {String} key The Game.Cache asset key of the Sprite Sheet image.
* @param {Number} frameWidth The fixed width of each frame of the animation.
* @param {Number} frameHeight The fixed height of each frame of the animation.
* @param {Number} [frameMax=-1] The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
*/
spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) {
// How big is our image?
@@ -55,7 +57,7 @@ Phaser.Animation.Parser = {
{
var uuid = game.rnd.uuid();
data.addFrame(new Phaser.Animation.Frame(x, y, frameWidth, frameHeight, '', uuid));
data.addFrame(new Phaser.Animation.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], {
x: x,
@@ -78,9 +80,13 @@ Phaser.Animation.Parser = {
},
/**
* Parse frame data from json texture atlas in Array format.
* @param json {object} Json data you want to parse.
* @return {FrameData} Generated FrameData object.
* Parse the JSON data and extract the animation frame data from it.
*
* @method JSONData
* @param {Phaser.Game} game A reference to the currently running game.
* @param {Object} json The JSON data from the Texture Atlas. Must be in Array format.
* @param {String} cacheKey The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
*/
JSONData: function (game, json, cacheKey) {
@@ -104,6 +110,7 @@ Phaser.Animation.Parser = {
var uuid = game.rnd.uuid();
newFrame = data.addFrame(new Phaser.Animation.Frame(
i,
frames[i].frame.x,
frames[i].frame.y,
frames[i].frame.w,
@@ -141,9 +148,13 @@ Phaser.Animation.Parser = {
},
/**
* Parse frame data from json texture atlas in Hash format.
* @param json {object} Json data you want to parse.
* @return {FrameData} Generated FrameData object.
* Parse the JSON data and extract the animation frame data from it.
*
* @method JSONDataHash
* @param {Phaser.Game} game A reference to the currently running game.
* @param {Object} json The JSON data from the Texture Atlas. Must be in JSON Hash format.
* @param {String} cacheKey The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
*/
JSONDataHash: function (game, json, cacheKey) {
@@ -161,12 +172,14 @@ Phaser.Animation.Parser = {
// By this stage frames is a fully parsed array
var frames = json['frames'];
var newFrame;
var i = 0;
for (var key in frames)
{
var uuid = game.rnd.uuid();
newFrame = data.addFrame(new Phaser.Animation.Frame(
i,
frames[key].frame.x,
frames[key].frame.y,
frames[key].frame.w,
@@ -197,6 +210,8 @@ Phaser.Animation.Parser = {
PIXI.TextureCache[uuid].realSize = frames[key].spriteSourceSize;
PIXI.TextureCache[uuid].trim.x = 0;
}
i++;
}
return data;
@@ -204,9 +219,13 @@ Phaser.Animation.Parser = {
},
/**
* Parse frame data from an XML file.
* @param xml {object} XML data you want to parse.
* @return {FrameData} Generated FrameData object.
* Parse the XML data and extract the animation frame data from it.
*
* @method XMLData
* @param {Phaser.Game} game A reference to the currently running game.
* @param {Object} xml The XML data from the Texture Atlas. Must be in Starling XML format.
* @param {String} cacheKey The Game.Cache asset key of the texture image.
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
*/
XMLData: function (game, xml, cacheKey) {
@@ -229,6 +248,7 @@ Phaser.Animation.Parser = {
var frame = frames[i].attributes;
newFrame = data.addFrame(new Phaser.Animation.Frame(
i,
frame.x.nodeValue,
frame.y.nodeValue,
frame.width.nodeValue,
+9
View File
@@ -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) {
+7
View File
@@ -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 Stage
* @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) {
+1 -1
View File
@@ -361,8 +361,8 @@ Phaser.StateManager.prototype = {
if (this._created == false && this.onCreateCallback)
{
// console.log('Create callback found');
this.onCreateCallback.call(this.callbackContext);
this._created = true;
this.onCreateCallback.call(this.callbackContext);
}
},
+6 -1
View File
@@ -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 destroy
*/
destroy: function () {
+5 -3
View File
@@ -19,10 +19,13 @@ Phaser.BitmapText = function (game, x, y, text, style) {
PIXI.BitmapText.call(this, text, style);
this.type = Phaser.BITMAPTEXT;
this.position.x = x;
this.position.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
this.anchor = new Phaser.Point();
this.scale = new Phaser.Point(1, 1);
// Influence of camera movement upon the position
@@ -51,11 +54,10 @@ Phaser.BitmapText = function (game, x, y, text, style) {
};
Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
// Add our own custom methods
/**
* Automatically called by World.update
*/
+11 -1
View File
@@ -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) {
+100 -19
View File
@@ -5,31 +5,112 @@ Phaser.Text = function (game, x, y, text, style) {
text = text || '';
style = style || '';
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
this.exists = true;
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
this.alive = true;
this.group = null;
this.name = '';
this.game = game;
PIXI.Text.call(this, text, style);
/*
this.canvas = document.createElement("canvas");
this.context = this.canvas.getContext("2d");
var canvasID = game.rnd.uuid();
PIXI.TextureCache[canvasID] = new PIXI.Texture(new PIXI.BaseTexture(this.canvas));
Phaser.Sprite.call(this, game, x, y, canvasID);
this.type = Phaser.TEXT;
this.setText(text);
this.setStyle(style);
this.updateText();
this.dirty = false;
*/
this.position.x = x;
this.position.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
this.anchor = new Phaser.Point();
this.scale = new Phaser.Point(1, 1);
// Influence of camera movement upon the position
this.scrollFactor = new Phaser.Point(1, 1);
// A mini cache for storing all of the calculated values
this._cache = {
dirty: false,
// Transform cache
a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
// The previous calculated position inc. camera x/y and scrollFactor
x: -1, y: -1,
// The actual scale values based on the worldTransform
scaleX: 1, scaleY: 1
};
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
this.renderable = true;
};
// Phaser.Text.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Text.prototype);
Phaser.Text.prototype = Phaser.Utils.extend(true, PIXI.Text.prototype);
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
Phaser.Text.prototype.constructor = Phaser.Text;
// Add our own custom methods
// Automatically called by World.update
Phaser.Text.prototype.update = function() {
if (!this.exists)
{
return;
}
this._cache.dirty = false;
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
if (this.position.x != this._cache.x || this.position.y != this._cache.y)
{
this.position.x = this._cache.x;
this.position.y = this._cache.y;
this._cache.dirty = true;
}
}
Object.defineProperty(Phaser.Text.prototype, 'angle', {
get: function() {
return Phaser.Math.radToDeg(this.rotation);
},
set: function(value) {
this.rotation = Phaser.Math.degToRad(value);
}
});
Object.defineProperty(Phaser.Text.prototype, 'x', {
get: function() {
return this.position.x;
},
set: function(value) {
this.position.x = value;
}
});
Object.defineProperty(Phaser.Text.prototype, 'y', {
get: function() {
return this.position.y;
},
set: function(value) {
this.position.y = value;
}
});
+27 -6
View File
@@ -86,6 +86,11 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
*/
this.particleDrag = new Phaser.Point();
/**
* The angular drag component of particles launched from the emitter if they are rotating.
*/
this.angularDrag = 0;
/**
* How often a particle is emitted in ms (if emitter is started with Explode == false).
*/
@@ -103,9 +108,9 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
this.lifespan = 2000;
/**
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
* How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
*/
this.bounce = 0;
this.bounce = new Phaser.Point();
/**
* Internal helper for deciding how many particles to launch.
@@ -204,7 +209,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
*
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
*/
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide) {
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {
if (typeof frames == 'undefined')
{
@@ -212,7 +217,12 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
}
quantity = quantity || this.maxParticles;
collide = collide || 0;
collide = collide || 0;
if (typeof collideWorldBounds == 'undefined')
{
collideWorldBounds = false;
}
var particle;
var i = 0;
@@ -250,6 +260,8 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
particle.body.allowCollision.none = true;
}
particle.body.collideWorldBounds = collideWorldBounds;
particle.exists = false;
particle.visible = false;
@@ -317,7 +329,15 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
this._explode = explode;
this.lifespan = lifespan;
this.frequency = frequency;
this._quantity += quantity;
if (explode)
{
this._quantity = quantity;
}
else
{
this._quantity += quantity;
}
this._counter = 0;
this._timer = this.game.time.now + frequency;
@@ -347,7 +367,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.lifespan = this.lifespan;
particle.body.bounce.setTo(this.bounce, this.bounce);
particle.body.bounce.setTo(this.bounce.x, this.bounce.y);
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
{
@@ -386,6 +406,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
particle.body.drag.x = this.particleDrag.x;
particle.body.drag.y = this.particleDrag.y;
particle.body.angularDrag = this.angularDrag;
}
+21 -6
View File
@@ -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 = '';
@@ -10,6 +20,7 @@ Phaser.Sound = function (game, key, volume, loop) {
this._volume = volume;
this.markers = {};
/**
* Reference to AudioContext instance.
*/
@@ -99,7 +110,7 @@ Phaser.Sound.prototype = {
addMarker: function (name, start, stop, volume, loop) {
volume = volume || 1;
loop = loop || false;
if (typeof loop == 'undefined') { loop = false; }
this.markers[name] = {
name: name,
@@ -177,7 +188,9 @@ Phaser.Sound.prototype = {
/**
* Play this sound, or a marked section of it.
* @param marker {string} Assets key of the sound you want to play.
* @param position {number} the starting position
* @param [volume] {number} volume of the sound you want to play.
* @param [loop] {bool} loop when it finished playing? (Default to false)
* @return {Sound} The playing sound object.
@@ -187,10 +200,12 @@ 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);
console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop);
if (this.isPlaying == true && forceRestart == false && this.override == false)
{
@@ -356,7 +371,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);
+15 -1
View File
@@ -1,6 +1,9 @@
/**
* Phaser - SoundManager
*
* @class SoundManager
* @constructor
* @param game {Phaser.Game} reference to the current game instance.
*/
Phaser.SoundManager = function (game) {
@@ -225,10 +228,21 @@ Phaser.SoundManager.prototype = {
},
/**
*
* @method add
* @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.
*/
add: function (key, volume, loop) {
volume = volume || 1;
loop = loop || false;
if (typeof loop == 'undefined') { loop = false; }
var sound = new Phaser.Sound(this.game, key, volume, loop);
+3
View File
@@ -69,6 +69,9 @@ Phaser.Utils = {
// deep, target, objects to copy to the target object
// This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/)
// deep (boolean)
// target (object to add to)
// objects ... (objects to recurse and copy from)
extend: function () {
var options, name, src, copy, copyIsArray, clone,