mirror of
https://github.com/wassname/phaser.git
synced 2026-08-04 13:14:14 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91c07ea37d | ||
|
|
d9a49797c4 | ||
|
|
a102859622 | ||
|
|
a899d24d4c |
@@ -1,11 +1,11 @@
|
||||

|
||||

|
||||
|
||||
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.
|
||||
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)
|
||||
|
||||
@@ -17,10 +17,8 @@ Try out the [Phaser Test Suite](http://gametest.mobi/phaser/)
|
||||
|
||||
"Being negative is not how we make progress" - Larry Page, Google
|
||||
|
||||
Latest Update
|
||||
-------------
|
||||
|
||||
September 13th 2013
|
||||
Welcome to Phaser
|
||||
-----------------
|
||||
|
||||
We're very pleased to have finally shipped the 1.0 release of Phaser. This version represents many months of hard work, feedback and refactoring based on the previous 0.5 through to 0.97 releases. You can see the full gory details in our change log.
|
||||
|
||||
@@ -37,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.
|
||||
@@ -164,8 +173,9 @@ The following list is not exhaustive and is subject to change:
|
||||
* Tilemap: more advanced Tiled support and support for DAME tilemaps.
|
||||
* Joypad support.
|
||||
* Gestures input class.
|
||||
* Flash CC html output support.
|
||||
|
||||
Right now our main focus is on documentation.
|
||||
Right now however our main focus is on documentation and examples, we won't be touching any of the above features until the docs are finished.
|
||||
|
||||
Test Suite
|
||||
----------
|
||||
@@ -185,9 +195,9 @@ You can also browse the [Phaser Test Suite](http://gametest.mobi/phaser/) online
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Phaser is in early stages and although we've still got a lot to add to it, we wanted to just get it out there and share it with the world.
|
||||
Phaser is in early stages and although we've still got a lot to add to it, we wanted to get it out there and share it with the world.
|
||||
|
||||
If you find a bug (highly likely!) then please report it on github.
|
||||
If you find a bug (highly likely!) then please report it on github or our forum.
|
||||
|
||||
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.
|
||||
|
||||
@@ -198,7 +208,7 @@ Bugs?
|
||||
|
||||
Please add them to the [Issue Tracker][1] with as much info as possible.
|
||||
|
||||

|
||||

|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Vendored
-1
File diff suppressed because one or more lines are too long
+975
-690
File diff suppressed because it is too large
Load Diff
Vendored
+1
File diff suppressed because one or more lines are too long
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
var Phaser = Phaser || {
|
||||
|
||||
VERSION: '1.0.3',
|
||||
VERSION: '1.0.4',
|
||||
GAMES: [],
|
||||
AUTO: 0,
|
||||
CANVAS: 1,
|
||||
|
||||
@@ -130,6 +130,7 @@ Phaser.Animation.prototype = {
|
||||
if (frameRate !== null)
|
||||
{
|
||||
this.delay = 1000 / frameRate;
|
||||
// this.delay = frameRate;
|
||||
}
|
||||
|
||||
if (loop !== null)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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 () {
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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]);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user