1.0.4 release

This commit is contained in:
Richard Davey
2013-09-18 06:34:56 +01:00
parent a102859622
commit d9a49797c4
15 changed files with 1071 additions and 728 deletions
+12 -1
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 uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
Version: 1.0.3 - Released: September 17th 2013
Version: 1.0.4 - Released: September 18th 2013
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
@@ -35,6 +35,17 @@ Phaser is everything we ever wanted from an HTML5 game framework. It will power
Change Log
----------
Version 1.0.4 (September 18th 2013)
* Small fix to Phaser.Canvas to stop it from setting overflow hidden if the parent DOM element doesn't exist.
* Added Loader.setPreloadSprite(sprite, direction) - this will automatically apply a crop rect to the Sprite which is updated in line with the load progress.
* A lot of changes inside the StateManager. State functions are now passed through link() which automatically creates the key Game properties (load, input, etc)
* Fixed a bug in getFrameByName that wouldn't return the first frame in the array.
* Updated Phaser.Rectangle.intersects to use x and y instead of left and top so it can be used to check Physics bodies overlapping.
* Fixed issue in Cache where the Frame index wasn't being set correctly (thanks Cameron)
* Fixed issue in Sprite where boundsY wasn't set (thanks Cameron)
* For some reason there were 2 copies of the Canvas class in the build file - fixed, a few KB saved :)
Version 1.0.3 (September 17th 2013)
* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function.
-1
View File
File diff suppressed because one or more lines are too long
+975 -690
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -3,7 +3,7 @@
*/
var Phaser = Phaser || {
VERSION: '1.0.3',
VERSION: '1.0.4',
GAMES: [],
AUTO: 0,
CANVAS: 1,
+2 -1
View File
@@ -129,7 +129,8 @@ Phaser.Animation.prototype = {
if (frameRate !== null)
{
this.delay = 1000 / frameRate;
// this.delay = 1000 / frameRate;
this.delay = frameRate;
}
if (loop !== null)
+1 -1
View File
@@ -359,7 +359,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
*/
set: function (value) {
if (this._frameData && this._frameData.getFrameByName(value))
if (this._frameData && this._frameData.getFrameByName(value) !== null)
{
this.currentFrame = this._frameData.getFrameByName(value);
this._frameIndex = this.currentFrame.index;
+1 -1
View File
@@ -82,7 +82,7 @@ Phaser.Animation.FrameData.prototype = {
*/
getFrameByName: function (name) {
if (this._frameNames[name] && this._frameNames[name] !== '')
if (typeof this._frameNames[name] === 'number')
{
return this._frames[this._frameNames[name]];
}
+1 -20
View File
@@ -31,25 +31,6 @@ Phaser.State = function () {
Phaser.State.prototype = {
link: function (game) {
this.game = game;
this.add = game.add;
this.camera = game.camera;
this.cache = game.cache;
this.input = game.input;
this.load = game.load;
this.math = game.math;
this.sound = game.sound;
this.stage = game.stage;
this.time = game.time;
this.tweens = game.tweens;
this.world = game.world;
this.particles = game.particles;
this.physics = game.physics;
},
/**
* Override this method to add some load operations.
* If you need to use the loader, you may need to use them here.
@@ -59,7 +40,7 @@ Phaser.State.prototype = {
/**
* This method is called after the game engine successfully switches states.
* Feel free to add any setup code here.(Do not load anything here, override init() instead)
* Feel free to add any setup code here.(Do not load anything here, override preload() instead)
*/
create: function () {
},
+23 -1
View File
@@ -145,7 +145,6 @@ Phaser.StateManager.prototype = {
{
// console.log('Phaser.StateManager.addState: Phaser.State given');
newState = state;
newState.link(this.game);
}
else if (typeof state === 'object')
{
@@ -326,12 +325,35 @@ Phaser.StateManager.prototype = {
return false;
}
},
link: function (key) {
// console.log('linked');
this.states[key].game = this.game;
this.states[key].add = this.game.add;
this.states[key].camera = this.game.camera;
this.states[key].cache = this.game.cache;
this.states[key].input = this.game.input;
this.states[key].load = this.game.load;
this.states[key].math = this.game.math;
this.states[key].sound = this.game.sound;
this.states[key].stage = this.game.stage;
this.states[key].time = this.game.time;
this.states[key].tweens = this.game.tweens;
this.states[key].world = this.game.world;
this.states[key].particles = this.game.particles;
this.states[key].physics = this.game.physics;
this.states[key].rnd = this.game.rnd;
},
setCurrentState: function (key) {
this.callbackContext = this.states[key];
this.link(key);
// Used when the state is set as being the current active state
this.onInitCallback = this.states[key]['init'] || this.dummy;
+1 -1
View File
@@ -290,7 +290,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
this.bounds.x -= this._cache.boundsX - this._cache.x;
this._cache.boundsX = this._cache.x;
this.bounds.y -= this._cache.boundsy - this._cache.y;
this.bounds.y -= this._cache.boundsY - this._cache.y;
this._cache.boundsY = this._cache.y;
}
}
+1 -1
View File
@@ -675,7 +675,7 @@ Phaser.Rectangle.intersects = function (a, b, tolerance) {
tolerance = tolerance || 0;
return !(a.left > b.right + tolerance || a.right < b.left - tolerance || a.top > b.bottom + tolerance || a.bottom < b.top - tolerance);
return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance);
};
+3 -3
View File
@@ -80,7 +80,7 @@ Phaser.Cache.prototype = {
*/
addRenderTexture: function (key, texture) {
var frame = new Phaser.Animation.Frame(0, 0, texture.width, texture.height, '', '');
var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', '');
this._textures[key] = { texture: texture, frame: frame };
@@ -177,7 +177,7 @@ Phaser.Cache.prototype = {
addDefaultImage: function () {
this._images['__default'] = { url: null, data: null, spriteSheet: false };
this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 32, 32, '', '');
this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 0, 32, 32, '', '');
var base = new PIXI.BaseTexture();
base.width = 32;
@@ -198,7 +198,7 @@ Phaser.Cache.prototype = {
addImage: function (key, url, data) {
this._images[key] = { url: url, data: data, spriteSheet: false };
this._images[key].frame = new Phaser.Animation.Frame(0, 0, data.width, data.height, '', '');
this._images[key].frame = new Phaser.Animation.Frame(0, 0, 0, data.width, data.height, '', '');
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
+42
View File
@@ -57,6 +57,12 @@ Phaser.Loader = function (game) {
*/
this.progress = 0;
/**
* You can optionally link a sprite to the preloader.
* If you do so the Sprite's width or height will be cropped based on the percentage loaded.
*/
this.preloadSprite = null;
/**
* The crossOrigin value applied to loaded images
* @type {string}
@@ -90,6 +96,27 @@ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
Phaser.Loader.prototype = {
setPreloadSprite: function (sprite, direction) {
direction = direction || 0;
this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null };
if (direction == 0)
{
// Horizontal crop
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 0, sprite.height);
}
else
{
// Vertical crop
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 0);
}
sprite.crop = this.preloadSprite.crop;
},
/**
* Check whether asset exists with a specific key.
* @param key {string} Key of the asset you want to check.
@@ -113,6 +140,7 @@ Phaser.Loader.prototype = {
*/
reset: function () {
this.preloadSprite = null;
this.queueSize = 0;
this.isLoading = false;
@@ -872,6 +900,20 @@ Phaser.Loader.prototype = {
this.progress = 100;
}
if (this.preloadSprite !== null)
{
if (this.preloadSprite.direction == 0)
{
this.preloadSprite.crop.width = (this.preloadSprite.width / 100) * this.progress;
}
else
{
this.preloadSprite.crop.height = (this.preloadSprite.height / 100) * this.progress;
}
this.preloadSprite.sprite.crop = this.preloadSprite.crop;
}
this.onFileComplete.dispatch(this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize);
if (this._keys.length > 0)
+7 -6
View File
@@ -103,23 +103,24 @@ Phaser.Canvas = {
addToDOM: function (canvas, parent, overflowHidden) {
parent = parent || '';
overflowHidden = overflowHidden || true;
if (typeof overflowHidden === 'undefined') { overflowHidden = true; }
if (parent !== '')
{
if (document.getElementById(parent))
{
document.getElementById(parent).appendChild(canvas);
if (overflowHidden)
{
document.getElementById(parent).style.overflow = 'hidden';
}
}
else
{
document.body.appendChild(canvas);
}
if (overflowHidden)
{
document.getElementById(parent).style.overflow = 'hidden';
}
}
else
{