mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Merged from dev.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||

|
||||
|
||||
Phaser 1.1.4
|
||||
Phaser 1.1.5
|
||||
============
|
||||
|
||||
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.1.4 "Kandor" - Released: February 5th 2014
|
||||
Version: 1.1.5 "Saldaea" - Released: 12th February 2014
|
||||
|
||||
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
|
||||
@@ -23,7 +23,7 @@ By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
Welcome to Phaser
|
||||
-----------------
|
||||
|
||||
Update: 10th February 2014 - Due to an issue with our TypeScript defintions file we have updated the `master` branch of Phaser. If you are having problems compiling with Visual Studio then please re-pull 1.1.4.
|
||||
This 1.1.5 release is released to address issues in 1.1.4 that we didn't want you to have to wait too long for.
|
||||
|
||||
As you may know we had planned to release 1.1.4 at the end of 2013. For various reasons this didn't quite happen, but we're happy to announce it's finally out! There have been some dramatic changes internally, and if you make use of either the physics systems or tilemaps then you are going to need to update your code. Hopefully only a little bit, but there have been a number of core API changes which we detail below. There are also a host of new features, the headliners being:
|
||||
|
||||
@@ -46,6 +46,12 @@ Phaser is everything we ever wanted from an HTML5 game framework. It powers all
|
||||

|
||||
|
||||
|
||||
Help Test 1.2
|
||||
-------------
|
||||
|
||||
You'll notice a new [1.2 branch](https://github.com/photonstorm/phaser/tree/1.2) on github. Please help test out 1.2 as much as you can. It features the brand new Pixi 1.5 internally as well as nearly complete integration with p2.js for all physics (dropping ArcadePhysics entirely). New versions are being pushed several times a day, so be sure to update and pull often. Don't expect to just run old games right under it yet, but please do check out the new tests, experiment and poke it around as much as you can - thank you!
|
||||
|
||||
|
||||
Getting Started Guides
|
||||
----------------------
|
||||
|
||||
@@ -59,181 +65,23 @@ There is also an [un-official Getting Started Guide](http://www.antonoffplus.com
|
||||
Change Log
|
||||
----------
|
||||
|
||||
Version 1.1.4 - "Kandor" - February 5th 2014
|
||||
|
||||
Significant API changes:
|
||||
|
||||
* Loader.tileset has been removed as it's no longer required, this was as part of the Tilemap system overhaul.
|
||||
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
|
||||
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
|
||||
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
|
||||
* Button.forceOut default value has changed from true to false, so Buttons will revert to an Up state (if set) when pressed and released.
|
||||
* The way the collision process callback works has changed significantly and now works as originally intended.
|
||||
* The World level quadtree is no longer created, they are now built and ripped down each time you collide a Group, this helps collision accuracy.
|
||||
* A SAT system has been integrated for Body collision and separation.
|
||||
* Bodies are no longer added to a world quadtree, so have had all of their quadtree properties removed such as skipQuadtree, quadTreeIndex, etc.
|
||||
* Body.drag has been removed. Please use the new Body.linearDamping value instead (which is a number value, not a Point object)
|
||||
* Body.embedded and Body.wasTouching have been removed as they are no longer required.
|
||||
* Body.customSeparateX/Y have been removed as you should now use Body.customSeparateCallback.
|
||||
* Body.maxVelocity defaults have been removed from 10,000 to 2000.
|
||||
* Body.customSeparateCallback allows you to set your own callback when two Bodies need to separate rather than using the built-in method.
|
||||
* Body.collideCallback allows you to set a callback that is fired whenever the Body is hit on any of its active faces.
|
||||
* Body.allowCollision has been renamed to Body.checkCollision.
|
||||
* Body.rebound is a boolean that controls if a body will exchange velocity on collision. Set to false to allow it to be 'pushed' (see new examples).
|
||||
* Removed Body.deltaAbsX and deltaAbsY as they are no longer used internally.
|
||||
* Body.screenX and screenY moved to getters, no longer calculated every frame.
|
||||
* ArcadePhysics now has setBounds and setBoundsToWorld, and you can specify which walls are created or not (left, right, up, down)
|
||||
* Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
|
||||
* Body.setSize has been removed. Please use Body.setCircle, setRectangle or setPolygon instead.
|
||||
|
||||
|
||||
New features:
|
||||
|
||||
* Phaser.Timer is now feature complete and fully documented. You can create Phaser.TimerEvents on a Timer and lots of new examples have been provided.
|
||||
* Gamepad API support has been added with lots of new examples (thanks Karl Macklin)
|
||||
* Phaser.Game constructor can now be passed a single object containing all of your game settings + Stage settings. Useful for advanced configurations.
|
||||
* The width/height given to Phaser.Game can now be percentages, i.e. "100%" will set the width to the maximum window innerWidth.
|
||||
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
|
||||
* Added support for margin and spacing around a frame in Loader.spritesheet.
|
||||
* Added Device.vibration to check if the Vibration API is available or not.
|
||||
* Added Device.trident and Device.tridentVersion for testing IE11.
|
||||
* Added Device.silk for detecting a Kindle Fire and updated desktop OS check to exclude Kindles (thanks LuckieLordie)
|
||||
* TilemapLayers now have debug and debugAlpha values, this turns on the drawing of the collision edges (very handy for debugging, as the name implies!)
|
||||
* Tweens have a new event: onLoop.
|
||||
* You can now load any binary file via the Loader: game.load.binary(key, url, callback) - the optional callback allows for post-load processing before entering the Cache.
|
||||
* Group.set will let you deep set a new propery on a single child of the Group.
|
||||
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
|
||||
* Added Ejecta detection to Device (thanks endel)
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value.
|
||||
* Buttons now properly use their upFrame if set.
|
||||
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
|
||||
* Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.
|
||||
* Groups can now be added to other Groups as children via group.add() and group.addAt()
|
||||
* Groups now have an 'alive' property, which can be useful when iterating through child groups with functions like forEachAlive.
|
||||
* Added a new Project Template "Full Screen Mobile" which you can find in the resources folder. Contains html / css / layout needed for a deployed Phaser game.
|
||||
* Body.speed - the current speed of the body.
|
||||
* Body.angle - the current angle the Body is facing based on its velocity. This is not the same as the Sprite angle that may own the body.
|
||||
* Body.linearDamping - This now replaces Body.drag and provides for a much smoother damping (friction) experience.
|
||||
* Body.minBounceVelocity - If a Body has bounce set, this threshold controls if it should rebound or not. Use it to stop 'jittering' on bounds/tiles with super-low velocities.
|
||||
* QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection.
|
||||
* Input.setMoveCallback allows you to set a callback that will be fired each time the activePointer receives a DOM move event.
|
||||
* Math.distancePow(x1,y1,x2,y2,power) returns the distance between two coordinates at the given power.
|
||||
* Physics.collide now supports the 2nd parameter as an array, for when you want to collide an object against a number of sprites that aren't all in the same Group.
|
||||
* Physics.overlap now supports the 2nd parameter as an array, for when you want to overlap test an object against a number of sprites that aren't all in the same Group.
|
||||
* Math.reverseAngle - reverses an angle (in radians).
|
||||
* Math.normalizeAngle - normalises an angle, now in radians only.
|
||||
* Math.normalizeLatitude - Normalizes a latitude to the [-90,90] range.
|
||||
* Math.normalizeLongitude - Normalizes a longitude to the [-180,180] range.
|
||||
* Phaser.Line added to the geometry classes, with full point on line/segment and intersection tests (see new examples)
|
||||
* Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
|
||||
* Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
|
||||
* Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
|
||||
* If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
|
||||
* Game.enableStep will enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?), very useful for debugging!
|
||||
* Game.disableStep turns core update loop stepping off.
|
||||
* Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
|
||||
* Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
|
||||
* Sprite.events.onBeginContact will be fired when a Body makes contact with another Body. Once contact is over an onEndContact event will be dispatched.
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
* Physics - Bounce by Patrick OReilly.
|
||||
* Physics - Bounce with gravity by Patrick OReilly.
|
||||
* Physics - Bounce accelerator (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Bounce knock (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Snake (use the keyboard to control the snake like creature) by Patrick OReilly and Richard Davey.
|
||||
* Physics - Launcher - Angry Birds style ball launcher demo by Patrick OReilly.
|
||||
* Physics - Launcher Follow - throw the sprite anywhere in the world by Patrick OReilly.
|
||||
* Physics - Launcher Follow World - an advanced version of the Launcher Follow example by Patrick OReilly.
|
||||
* Input - Touch Joystick example showing how to use the clay.io virtual game controller (thanks gabehollombe)
|
||||
* Games - Matching Pairs by Patrick OReilly.
|
||||
* Games - Simon Says by Patrick OReilly.
|
||||
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
|
||||
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
|
||||
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
|
||||
* Animation - Group Creation, showing how to create animations across all Group children in one call.
|
||||
* Particles - Rain by Jens Anders Bakke.
|
||||
* Particles - Snow by Jens Anders Bakke.
|
||||
* Groups - Nested Groups - showing how to embed one Group into another Group.
|
||||
* Time - Lots of new examples showing how to use the updated Phaser.Timer class.
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
* Updated to latest Pixi.js dev branch build (pre 1.4 release)
|
||||
* When a Sprite is destroyed any active filters are removed at the same time.
|
||||
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
|
||||
* Phaser.Canvas.create updated so it can be given an ID as the 3rd parameter (can also be set via new Game configuration object).
|
||||
* Updated display/fullscreen example to reflect new full screen change.
|
||||
* Loads of updates to the TypeScript definitions files - games fully compile now and lots of missing classes added :) (thanks Niondir)
|
||||
* Removed 'null parent' check from Group constructor. Will parent to game.world only if parent value is undefined.
|
||||
* The tutorials have now been translated into Spanish - thanks feiss :)
|
||||
* separateY updated to re-implement the 'riding platforms' special condition (thanks cocoademon)
|
||||
* SoundManager.onSoundDecode now dispatches the key followed by the sound object, also now dispatched by the Cache when doing an auto-decode on load.
|
||||
* Switch method of using trimmed sprites to support scaling and rotation (thanks cocoademon)
|
||||
* Most of the GameObjectFactory functions now have a group parameter, so you can do: game.add.sprite(x, y, frame, frameName, group) rather than defaulting to the World group.
|
||||
* Group.countLiving and countDead used to return -1 if the Group was empty, but now return 0.
|
||||
* Text can now be fixedToCamera, updated world/fixed to camera example to show this.
|
||||
* ArcadePhysics.overlap and collide now recognise TileSprites in the collision checks.
|
||||
* Lots of documentation fixes in the Tween class.
|
||||
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
|
||||
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself. This will check all children against each other, but not themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
|
||||
* Group.destroy has a new parameter: destroyChildren (boolean) which will optionally call the destroy method of all Group children.
|
||||
* Button.clearFrames method has been added.
|
||||
* Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.
|
||||
* Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
|
||||
* The Time class now has its own Phaser.Timer which you can access through game.time.events. See the new Timer examples to show how to use them.
|
||||
* Added StateManager.getCurrentState to return the currently running State object (thanks Niondir)
|
||||
* Removed the console.log redirect from Utils as it was messing with Firefox.
|
||||
* Body.acceleration is now much smoother and less eratic at high speeds.
|
||||
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
|
||||
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
|
||||
* Body.bottom and Body.right are no longer rounded, so will give accurate sub-pixel values.
|
||||
* Fixed lots of documentation in the Emitter class.
|
||||
* The delta timer value used for physics calculations has had its cap limit modified from 1.0 to 0.05 in line with the core updates.
|
||||
* Phaser.Math.min enhanced so you can now pass in either an array of numbers or lots of numbers as parameters to get the lowest.
|
||||
* Phaser.Math.max added as the opposite of Math.min.
|
||||
* Phaser.Math.minProperty and maxProperty added. Like Math.min/max but can be given a property an an array or list of objects to inspect.
|
||||
* Added 'full' paramter to Body.reset, allowing you to control if motion or all data is reset or not.
|
||||
* Exposed Group.pivot and Sprite.pivot to allow you to directly set the pivot points for rotation.
|
||||
* Swapped to using the native and faster Array.isArray check.
|
||||
* Added callback context parameter to Tween.onUpdateCallback(callback, context) to avoid having to bind or create anonymous functions.
|
||||
* Updated TweenManager.removeAll so it flags all tweens as pendingDelete rather than nuking the array, to avoid tween callback array size errors (thanks DarkDev)
|
||||
|
||||
Version 1.1.5 - "Saldaea" - 12th February 2014
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Cache.getImageKeys returned __missing in the array, now excluded.
|
||||
* Fixed Group.scale so you can now scale a Group directly.
|
||||
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
||||
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
|
||||
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group has no children.
|
||||
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
|
||||
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
|
||||
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
|
||||
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
|
||||
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
|
||||
* RenderTexture now displays correctly in Canvas games.
|
||||
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
|
||||
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
|
||||
* Patched desyrel.xml so it doesn't contain any zero width/height characters, as they broke Firefox 25.
|
||||
* Cache.addSound now implements a locked attribute (thanks haden)
|
||||
* Sound now checks for CocoonJS during playback to avoid readyState clash (thanks haden)
|
||||
* Buttons now clear previously set frames correctly if you call setFrames.
|
||||
* Sounds will now loop correctly if they are paused and resumed (thanks haden)
|
||||
* InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not.
|
||||
* Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it.
|
||||
* Fixed WebGLRenderer updateGraphics bug (thanks theadam)
|
||||
* Removed duplicate Timer.create line (thanks hstolte)
|
||||
* Fixed issue with the camera being slightly out of sync with 'fixedToCamera' sprites.
|
||||
* 1px camera jitter issue fixed where map is same size, or smaller than the game size.
|
||||
* Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
|
||||
* Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee)
|
||||
* Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy)
|
||||
* Added SAT.js to TypeScript definition. Now compiles properly.
|
||||
* Added missing Line.js to the Grunt file.
|
||||
* Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep)
|
||||
* Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64).
|
||||
* Fixed easing tween example case. Issue #379 (thanks wesleywerner)
|
||||
* Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
|
||||
|
||||
|
||||
See the full Change Log for all the 1.1.4 updates and API changes (as there were a lot of them!)
|
||||
|
||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
|
||||
|
||||
@@ -381,13 +229,9 @@ Road Map
|
||||
|
||||
Here is what's on our road map for the coming months:
|
||||
|
||||
Version 1.1.5 ("Saldaea")
|
||||
|
||||
* A fast turn-around point release that will focus on addressing any bugs that occured as a result of the large changes that took place in 1.1.4.
|
||||
|
||||
Version 1.2 ("Shienar")
|
||||
|
||||
* Update to Pixi 1.4 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
* Update to Pixi 1.5 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
|
||||
Version 1.3 ("Tarabon")
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "phaser",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"homepage": "http://phaser.io",
|
||||
"authors": [
|
||||
"photonstorm <rich@photonstorm.com>"
|
||||
|
||||
+109
-102
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v1.1.4 - Built at: Wed Feb 05 2014 16:54:13
|
||||
* v1.1.5 - Built at: Wed Feb 12 2014 15:08:44
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -57,8 +57,8 @@ var PIXI = PIXI || {};
|
||||
*/
|
||||
var Phaser = Phaser || {
|
||||
|
||||
VERSION: '1.1.4',
|
||||
DEV_VERSION: '1.1.4',
|
||||
VERSION: '1.1.5',
|
||||
DEV_VERSION: '1.1.5',
|
||||
GAMES: [],
|
||||
|
||||
AUTO: 0,
|
||||
@@ -139,9 +139,9 @@ Phaser.Utils = {
|
||||
* dir = 1 (left), 2 (right), 3 (both)
|
||||
* @method Phaser.Utils.pad
|
||||
* @param {string} str - The target string.
|
||||
* @param {number} len - Description.
|
||||
* @param {number} pad - the string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @param {number} len - The number of characters to be added.
|
||||
* @param {number} pad - The string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] The direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @return {string} The padded string
|
||||
*/
|
||||
pad: function (str, len, pad, dir) {
|
||||
@@ -31173,7 +31173,7 @@ Phaser.Timer.prototype = {
|
||||
{
|
||||
if (this.events[i] === event)
|
||||
{
|
||||
this.events.splice(i, 1);
|
||||
this.events[i].pendingDelete = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -31236,6 +31236,21 @@ Phaser.Timer.prototype = {
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
this._i = 0;
|
||||
|
||||
while (this._i < this._len)
|
||||
{
|
||||
if (this.events[this._i].pendingDelete)
|
||||
{
|
||||
this.events.splice(this._i, 1);
|
||||
this._len--;
|
||||
}
|
||||
|
||||
this._i++;
|
||||
}
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
if (this.running && this._now >= this.nextTick && this._len > 0)
|
||||
{
|
||||
this._i = 0;
|
||||
@@ -31299,9 +31314,12 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
pause: function () {
|
||||
|
||||
this._pauseStarted = this.game.time.now;
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this._pauseStarted = this.game.time.now;
|
||||
|
||||
this.paused = true;
|
||||
this.paused = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -31311,17 +31329,20 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
resume: function () {
|
||||
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -31333,6 +31354,7 @@ Phaser.Timer.prototype = {
|
||||
this.onComplete.removeAll();
|
||||
this.running = false;
|
||||
this.events = [];
|
||||
this._i = this._len;
|
||||
|
||||
}
|
||||
|
||||
@@ -31478,6 +31500,12 @@ Phaser.TimerEvent = function (timer, delay, tick, repeatCount, loop, callback, c
|
||||
*/
|
||||
this.args = args;
|
||||
|
||||
/**
|
||||
* @property {boolean} pendingDelete - A flag that controls if the TimerEvent is pending deletion.
|
||||
* @protected
|
||||
*/
|
||||
this.pendingDelete = false;
|
||||
|
||||
};
|
||||
|
||||
Phaser.TimerEvent.prototype.constructor = Phaser.TimerEvent;
|
||||
@@ -37955,33 +37983,7 @@ Phaser.Color = {
|
||||
// polygons using the Separating Axis Theorem.
|
||||
/** @preserve SAT.js - Version 0.2 - Copyright 2013 - Jim Riecken <jimr@jimr.ca> - released under the MIT License. https://github.com/jriecken/sat-js */
|
||||
|
||||
/*global define: false, module: false*/
|
||||
/*jshint shadow:true, sub:true, forin:true, noarg:true, noempty:true,
|
||||
eqeqeq:true, bitwise:true, strict:true, undef:true,
|
||||
curly:true, browser:true */
|
||||
|
||||
// Create a UMD wrapper for SAT. Works in:
|
||||
//
|
||||
// - Plain browser via global SAT variable
|
||||
// - AMD loader (like require.js)
|
||||
// - Node.js
|
||||
//
|
||||
// The quoted properties all over the place are used so that the Closure Compiler
|
||||
// does not mangle the exposed API in advanced mode.
|
||||
/**
|
||||
* @param {*} root - The global scope
|
||||
* @param {Function} factory - Factory that creates SAT module
|
||||
*/
|
||||
(function (root, factory) {
|
||||
"use strict";
|
||||
if (typeof define === 'function' && define['amd']) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module['exports'] = factory();
|
||||
} else {
|
||||
root['SAT'] = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
var SAT = (function () {
|
||||
"use strict";
|
||||
|
||||
var SAT = {};
|
||||
@@ -37994,7 +37996,7 @@ Phaser.Color = {
|
||||
|
||||
// Create a new Vector, optionally passing in the `x` and `y` coordinates. If
|
||||
// a coordinate is not specified, it will be set to `0`
|
||||
/**
|
||||
/**
|
||||
* @param {?number=} x The x position.
|
||||
* @param {?number=} y The y position.
|
||||
* @constructor
|
||||
@@ -38067,7 +38069,7 @@ Phaser.Color = {
|
||||
this['y'] = -this['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Normalize this vector. (make it have length of `1`)
|
||||
/**
|
||||
@@ -38081,7 +38083,7 @@ Phaser.Color = {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Add another vector to this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -38092,7 +38094,7 @@ Phaser.Color = {
|
||||
this['y'] += other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Subtract another vector from this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -38103,7 +38105,7 @@ Phaser.Color = {
|
||||
this['y'] -= other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Scale this vector. An independant scaling factor can be provided
|
||||
// for each axis, or a single scaling factor that will scale both `x` and `y`.
|
||||
/**
|
||||
@@ -38115,9 +38117,9 @@ Phaser.Color = {
|
||||
Vector.prototype['scale'] = Vector.prototype.scale = function(x,y) {
|
||||
this['x'] *= x;
|
||||
this['y'] *= y || x;
|
||||
return this;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector on to another vector.
|
||||
/**
|
||||
* @param {Vector} other The vector to project onto.
|
||||
@@ -38129,7 +38131,7 @@ Phaser.Color = {
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector onto a vector of unit length. This is slightly more efficient
|
||||
// than `project` when dealing with unit vectors.
|
||||
/**
|
||||
@@ -38142,7 +38144,7 @@ Phaser.Color = {
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis.
|
||||
/**
|
||||
* @param {Vector} axis The vector representing the axis.
|
||||
@@ -38156,7 +38158,7 @@ Phaser.Color = {
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis (represented by a unit vector). This is
|
||||
// slightly more efficient than `reflect` when dealing with an axis that is a unit vector.
|
||||
/**
|
||||
@@ -38171,7 +38173,7 @@ Phaser.Color = {
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Get the dot product of this vector and another.
|
||||
/**
|
||||
* @param {Vector} other The vector to dot this one against.
|
||||
@@ -38180,7 +38182,7 @@ Phaser.Color = {
|
||||
Vector.prototype['dot'] = Vector.prototype.dot = function(other) {
|
||||
return this['x'] * other['x'] + this['y'] * other['y'];
|
||||
};
|
||||
|
||||
|
||||
// Get the squared length of this vector.
|
||||
/**
|
||||
* @return {number} The length^2 of this vector.
|
||||
@@ -38188,7 +38190,7 @@ Phaser.Color = {
|
||||
Vector.prototype['len2'] = Vector.prototype.len2 = function() {
|
||||
return this.dot(this);
|
||||
};
|
||||
|
||||
|
||||
// Get the length of this vector.
|
||||
/**
|
||||
* @return {number} The length of this vector.
|
||||
@@ -38196,7 +38198,7 @@ Phaser.Color = {
|
||||
Vector.prototype['len'] = Vector.prototype.len = function() {
|
||||
return Math.sqrt(this.len2());
|
||||
};
|
||||
|
||||
|
||||
// ## Circle
|
||||
//
|
||||
// Represents a circle with a position and a radius.
|
||||
@@ -38239,7 +38241,7 @@ Phaser.Color = {
|
||||
this.recalc();
|
||||
}
|
||||
SAT['Polygon'] = Polygon;
|
||||
|
||||
|
||||
// Recalculates the edges and normals of the polygon. This **must** be called
|
||||
// if the `points` array is modified at all and the edges or normals are to be
|
||||
// accessed.
|
||||
@@ -38258,7 +38260,7 @@ Phaser.Color = {
|
||||
var points = this['points'];
|
||||
var len = points.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var p1 = points[i];
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vector().copy(p2).sub(p1);
|
||||
var n = new Vector().copy(e).perp().normalize();
|
||||
@@ -38367,11 +38369,11 @@ Phaser.Color = {
|
||||
var w = this['w'];
|
||||
var h = this['h'];
|
||||
return new Polygon(new Vector(pos['x'], pos['y']), [
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(w,h), new Vector(0,h)
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
// ## Response
|
||||
//
|
||||
// An object representing the result of an intersection. Contains:
|
||||
@@ -38382,7 +38384,7 @@ Phaser.Color = {
|
||||
// - Whether the first object is entirely inside the second, and vice versa.
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
*/
|
||||
function Response() {
|
||||
this['a'] = null;
|
||||
this['b'] = null;
|
||||
@@ -38414,7 +38416,7 @@ Phaser.Color = {
|
||||
*/
|
||||
var T_VECTORS = [];
|
||||
for (var i = 0; i < 10; i++) { T_VECTORS.push(new Vector()); }
|
||||
|
||||
|
||||
// A pool of arrays of numbers used in calculations to avoid allocating
|
||||
// memory.
|
||||
/**
|
||||
@@ -38447,7 +38449,7 @@ Phaser.Color = {
|
||||
}
|
||||
result[0] = min; result[1] = max;
|
||||
}
|
||||
|
||||
|
||||
// Check whether two convex polygons are separated by the specified
|
||||
// axis (must be a unit vector).
|
||||
/**
|
||||
@@ -38477,8 +38479,8 @@ Phaser.Color = {
|
||||
rangeB[1] += projectedOffset;
|
||||
// Check if there is a gap. If there is, this is a separating axis and we can stop
|
||||
if (rangeA[0] > rangeB[1] || rangeB[0] > rangeA[1]) {
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return true;
|
||||
}
|
||||
@@ -38489,7 +38491,7 @@ Phaser.Color = {
|
||||
if (rangeA[0] < rangeB[0]) {
|
||||
response['aInB'] = false;
|
||||
// A ends before B does. We have to pull A out of B
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
overlap = rangeA[1] - rangeB[0];
|
||||
response['bInA'] = false;
|
||||
// B is fully inside A. Pick the shortest way out.
|
||||
@@ -38502,7 +38504,7 @@ Phaser.Color = {
|
||||
} else {
|
||||
response['bInA'] = false;
|
||||
// B ends before A ends. We have to push A out of B
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
overlap = rangeA[0] - rangeB[1];
|
||||
response['aInB'] = false;
|
||||
// A is fully inside B. Pick the shortest way out.
|
||||
@@ -38520,14 +38522,14 @@ Phaser.Color = {
|
||||
if (overlap < 0) {
|
||||
response['overlapN'].reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Calculates which Vornoi region a point is on a line segment.
|
||||
// It is assumed that both the line and the point are relative to `(0,0)`
|
||||
//
|
||||
@@ -38537,8 +38539,8 @@ Phaser.Color = {
|
||||
/**
|
||||
* @param {Vector} line The line segment.
|
||||
* @param {Vector} point The point.
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
||||
*/
|
||||
function vornoiRegion(line, point) {
|
||||
@@ -38566,7 +38568,7 @@ Phaser.Color = {
|
||||
* @const
|
||||
*/
|
||||
var RIGHT_VORNOI_REGION = 1;
|
||||
|
||||
|
||||
// ## Collision Tests
|
||||
|
||||
// Check if two circles collide.
|
||||
@@ -38575,7 +38577,7 @@ Phaser.Color = {
|
||||
* @param {Circle} b The second circle.
|
||||
* @param {Response=} response Response object (optional) that will be populated if
|
||||
* the circles intersect.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
*/
|
||||
function testCircleCircle(a, b, response) {
|
||||
// Check if the distance between the centers of the two
|
||||
@@ -38590,7 +38592,7 @@ Phaser.Color = {
|
||||
return false;
|
||||
}
|
||||
// They intersect. If we're calculating a response, calculate the overlap.
|
||||
if (response) {
|
||||
if (response) {
|
||||
var dist = Math.sqrt(distanceSq);
|
||||
response['a'] = a;
|
||||
response['b'] = b;
|
||||
@@ -38604,7 +38606,7 @@ Phaser.Color = {
|
||||
return true;
|
||||
}
|
||||
SAT['testCircleCircle'] = testCircleCircle;
|
||||
|
||||
|
||||
// Check if a polygon and a circle collide.
|
||||
/**
|
||||
* @param {Polygon} polygon The polygon.
|
||||
@@ -38622,30 +38624,30 @@ Phaser.Color = {
|
||||
var len = points.length;
|
||||
var edge = T_VECTORS.pop();
|
||||
var point = T_VECTORS.pop();
|
||||
|
||||
|
||||
// For each edge in the polygon:
|
||||
for (var i = 0; i < len; i++) {
|
||||
var next = i === len - 1 ? 0 : i + 1;
|
||||
var prev = i === 0 ? len - 1 : i - 1;
|
||||
var overlap = 0;
|
||||
var overlapN = null;
|
||||
|
||||
|
||||
// Get the edge.
|
||||
edge.copy(polygon['edges'][i]);
|
||||
// Calculate the center of the circle relative to the starting point of the edge.
|
||||
point.copy(circlePos).sub(points[i]);
|
||||
|
||||
|
||||
// If the distance between the center of the circle and the point
|
||||
// is bigger than the radius, the polygon is definitely not fully in
|
||||
// the circle.
|
||||
if (response && point.len2() > radius2) {
|
||||
response['aInB'] = false;
|
||||
}
|
||||
|
||||
|
||||
// Calculate which Vornoi region the center of the circle is in.
|
||||
var region = vornoiRegion(edge, point);
|
||||
// If it's the left region:
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
// We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge.
|
||||
edge.copy(polygon['edges'][prev]);
|
||||
// Calculate the center of the circle relative the starting point of the previous edge
|
||||
@@ -38656,9 +38658,9 @@ Phaser.Color = {
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point2);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -38681,10 +38683,10 @@ Phaser.Color = {
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
return false;
|
||||
} else if (response) {
|
||||
// It intersects, calculate the overlap.
|
||||
response['bInA'] = false;
|
||||
@@ -38697,15 +38699,15 @@ Phaser.Color = {
|
||||
// Need to check if the circle is intersecting the edge,
|
||||
// Change the edge into its "edge normal".
|
||||
var normal = edge.perp().normalize();
|
||||
// Find the perpendicular distance between the center of the
|
||||
// Find the perpendicular distance between the center of the
|
||||
// circle and the edge.
|
||||
var dist = point.dot(normal);
|
||||
var distAbs = Math.abs(dist);
|
||||
// If the circle is on the outside of the edge, there is no intersection.
|
||||
if (dist > 0 && distAbs > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -38719,28 +38721,28 @@ Phaser.Color = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
// (overlapN may be null if the circle was in the wrong Vornoi region).
|
||||
if (overlapN && response && Math.abs(overlap) < Math.abs(response['overlap'])) {
|
||||
response['overlap'] = overlap;
|
||||
response['overlapN'].copy(overlapN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate the final overlap vector - based on the smallest overlap.
|
||||
if (response) {
|
||||
response['a'] = polygon;
|
||||
response['b'] = circle;
|
||||
response['overlapV'].copy(response['overlapN']).scale(response['overlap']);
|
||||
}
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return true;
|
||||
}
|
||||
SAT['testPolygonCircle'] = testPolygonCircle;
|
||||
|
||||
|
||||
// Check if a circle and a polygon collide.
|
||||
//
|
||||
// **NOTE:** This is slightly less efficient than polygonCircle as it just
|
||||
@@ -38769,7 +38771,7 @@ Phaser.Color = {
|
||||
return result;
|
||||
}
|
||||
SAT['testCirclePolygon'] = testCirclePolygon;
|
||||
|
||||
|
||||
// Checks whether polygons collide.
|
||||
/**
|
||||
* @param {Polygon} a The first polygon.
|
||||
@@ -38808,7 +38810,8 @@ Phaser.Color = {
|
||||
SAT['testPolygonPolygon'] = testPolygonPolygon;
|
||||
|
||||
return SAT;
|
||||
}));
|
||||
})();
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
@@ -41223,7 +41226,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.LEFT, this, body, response))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.right || this.touching.right)
|
||||
@@ -41247,6 +41250,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.left = true;
|
||||
body.touching.right = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -41270,7 +41275,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.RIGHT, this, body))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.left || this.touching.left)
|
||||
@@ -41294,6 +41299,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.right = true;
|
||||
body.touching.left = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+7
-7
File diff suppressed because one or more lines are too long
+176
@@ -1,6 +1,182 @@
|
||||
Change Log
|
||||
==========
|
||||
|
||||
Version 1.1.4 - "Kandor" - February 5th 2014
|
||||
--------------------------------------------
|
||||
|
||||
Significant API changes:
|
||||
|
||||
* Loader.tileset has been removed as it's no longer required, this was as part of the Tilemap system overhaul.
|
||||
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
|
||||
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
|
||||
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
|
||||
* Button.forceOut default value has changed from true to false, so Buttons will revert to an Up state (if set) when pressed and released.
|
||||
* The way the collision process callback works has changed significantly and now works as originally intended.
|
||||
* The World level quadtree is no longer created, they are now built and ripped down each time you collide a Group, this helps collision accuracy.
|
||||
* A SAT system has been integrated for Body collision and separation.
|
||||
* Bodies are no longer added to a world quadtree, so have had all of their quadtree properties removed such as skipQuadtree, quadTreeIndex, etc.
|
||||
* Body.drag has been removed. Please use the new Body.linearDamping value instead (which is a number value, not a Point object)
|
||||
* Body.embedded and Body.wasTouching have been removed as they are no longer required.
|
||||
* Body.customSeparateX/Y have been removed as you should now use Body.customSeparateCallback.
|
||||
* Body.maxVelocity defaults have been removed from 10,000 to 2000.
|
||||
* Body.customSeparateCallback allows you to set your own callback when two Bodies need to separate rather than using the built-in method.
|
||||
* Body.collideCallback allows you to set a callback that is fired whenever the Body is hit on any of its active faces.
|
||||
* Body.allowCollision has been renamed to Body.checkCollision.
|
||||
* Body.rebound is a boolean that controls if a body will exchange velocity on collision. Set to false to allow it to be 'pushed' (see new examples).
|
||||
* Removed Body.deltaAbsX and deltaAbsY as they are no longer used internally.
|
||||
* Body.screenX and screenY moved to getters, no longer calculated every frame.
|
||||
* ArcadePhysics now has setBounds and setBoundsToWorld, and you can specify which walls are created or not (left, right, up, down)
|
||||
* Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
|
||||
* Body.setSize has been removed. Please use Body.setCircle, setRectangle or setPolygon instead.
|
||||
|
||||
|
||||
New features:
|
||||
|
||||
* Phaser.Timer is now feature complete and fully documented. You can create Phaser.TimerEvents on a Timer and lots of new examples have been provided.
|
||||
* Gamepad API support has been added with lots of new examples (thanks Karl Macklin)
|
||||
* Phaser.Game constructor can now be passed a single object containing all of your game settings + Stage settings. Useful for advanced configurations.
|
||||
* The width/height given to Phaser.Game can now be percentages, i.e. "100%" will set the width to the maximum window innerWidth.
|
||||
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
|
||||
* Added support for margin and spacing around a frame in Loader.spritesheet.
|
||||
* Added Device.vibration to check if the Vibration API is available or not.
|
||||
* Added Device.trident and Device.tridentVersion for testing IE11.
|
||||
* Added Device.silk for detecting a Kindle Fire and updated desktop OS check to exclude Kindles (thanks LuckieLordie)
|
||||
* TilemapLayers now have debug and debugAlpha values, this turns on the drawing of the collision edges (very handy for debugging, as the name implies!)
|
||||
* Tweens have a new event: onLoop.
|
||||
* You can now load any binary file via the Loader: game.load.binary(key, url, callback) - the optional callback allows for post-load processing before entering the Cache.
|
||||
* Group.set will let you deep set a new propery on a single child of the Group.
|
||||
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
|
||||
* Added Ejecta detection to Device (thanks endel)
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value.
|
||||
* Buttons now properly use their upFrame if set.
|
||||
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
|
||||
* Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.
|
||||
* Groups can now be added to other Groups as children via group.add() and group.addAt()
|
||||
* Groups now have an 'alive' property, which can be useful when iterating through child groups with functions like forEachAlive.
|
||||
* Added a new Project Template "Full Screen Mobile" which you can find in the resources folder. Contains html / css / layout needed for a deployed Phaser game.
|
||||
* Body.speed - the current speed of the body.
|
||||
* Body.angle - the current angle the Body is facing based on its velocity. This is not the same as the Sprite angle that may own the body.
|
||||
* Body.linearDamping - This now replaces Body.drag and provides for a much smoother damping (friction) experience.
|
||||
* Body.minBounceVelocity - If a Body has bounce set, this threshold controls if it should rebound or not. Use it to stop 'jittering' on bounds/tiles with super-low velocities.
|
||||
* QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection.
|
||||
* Input.setMoveCallback allows you to set a callback that will be fired each time the activePointer receives a DOM move event.
|
||||
* Math.distancePow(x1,y1,x2,y2,power) returns the distance between two coordinates at the given power.
|
||||
* Physics.collide now supports the 2nd parameter as an array, for when you want to collide an object against a number of sprites that aren't all in the same Group.
|
||||
* Physics.overlap now supports the 2nd parameter as an array, for when you want to overlap test an object against a number of sprites that aren't all in the same Group.
|
||||
* Math.reverseAngle - reverses an angle (in radians).
|
||||
* Math.normalizeAngle - normalises an angle, now in radians only.
|
||||
* Math.normalizeLatitude - Normalizes a latitude to the [-90,90] range.
|
||||
* Math.normalizeLongitude - Normalizes a longitude to the [-180,180] range.
|
||||
* Phaser.Line added to the geometry classes, with full point on line/segment and intersection tests (see new examples)
|
||||
* Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
|
||||
* Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
|
||||
* Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
|
||||
* If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
|
||||
* Game.enableStep will enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?), very useful for debugging!
|
||||
* Game.disableStep turns core update loop stepping off.
|
||||
* Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
|
||||
* Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
|
||||
* Sprite.events.onBeginContact will be fired when a Body makes contact with another Body. Once contact is over an onEndContact event will be dispatched.
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
* Physics - Bounce by Patrick OReilly.
|
||||
* Physics - Bounce with gravity by Patrick OReilly.
|
||||
* Physics - Bounce accelerator (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Bounce knock (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Snake (use the keyboard to control the snake like creature) by Patrick OReilly and Richard Davey.
|
||||
* Physics - Launcher - Angry Birds style ball launcher demo by Patrick OReilly.
|
||||
* Physics - Launcher Follow - throw the sprite anywhere in the world by Patrick OReilly.
|
||||
* Physics - Launcher Follow World - an advanced version of the Launcher Follow example by Patrick OReilly.
|
||||
* Input - Touch Joystick example showing how to use the clay.io virtual game controller (thanks gabehollombe)
|
||||
* Games - Matching Pairs by Patrick OReilly.
|
||||
* Games - Simon Says by Patrick OReilly.
|
||||
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
|
||||
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
|
||||
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
|
||||
* Animation - Group Creation, showing how to create animations across all Group children in one call.
|
||||
* Particles - Rain by Jens Anders Bakke.
|
||||
* Particles - Snow by Jens Anders Bakke.
|
||||
* Groups - Nested Groups - showing how to embed one Group into another Group.
|
||||
* Time - Lots of new examples showing how to use the updated Phaser.Timer class.
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
* Updated to latest Pixi.js dev branch build (pre 1.4 release)
|
||||
* When a Sprite is destroyed any active filters are removed at the same time.
|
||||
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
|
||||
* Phaser.Canvas.create updated so it can be given an ID as the 3rd parameter (can also be set via new Game configuration object).
|
||||
* Updated display/fullscreen example to reflect new full screen change.
|
||||
* Loads of updates to the TypeScript definitions files - games fully compile now and lots of missing classes added :) (thanks Niondir)
|
||||
* Removed 'null parent' check from Group constructor. Will parent to game.world only if parent value is undefined.
|
||||
* The tutorials have now been translated into Spanish - thanks feiss :)
|
||||
* separateY updated to re-implement the 'riding platforms' special condition (thanks cocoademon)
|
||||
* SoundManager.onSoundDecode now dispatches the key followed by the sound object, also now dispatched by the Cache when doing an auto-decode on load.
|
||||
* Switch method of using trimmed sprites to support scaling and rotation (thanks cocoademon)
|
||||
* Most of the GameObjectFactory functions now have a group parameter, so you can do: game.add.sprite(x, y, frame, frameName, group) rather than defaulting to the World group.
|
||||
* Group.countLiving and countDead used to return -1 if the Group was empty, but now return 0.
|
||||
* Text can now be fixedToCamera, updated world/fixed to camera example to show this.
|
||||
* ArcadePhysics.overlap and collide now recognise TileSprites in the collision checks.
|
||||
* Lots of documentation fixes in the Tween class.
|
||||
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
|
||||
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself. This will check all children against each other, but not themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
|
||||
* Group.destroy has a new parameter: destroyChildren (boolean) which will optionally call the destroy method of all Group children.
|
||||
* Button.clearFrames method has been added.
|
||||
* Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.
|
||||
* Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
|
||||
* The Time class now has its own Phaser.Timer which you can access through game.time.events. See the new Timer examples to show how to use them.
|
||||
* Added StateManager.getCurrentState to return the currently running State object (thanks Niondir)
|
||||
* Removed the console.log redirect from Utils as it was messing with Firefox.
|
||||
* Body.acceleration is now much smoother and less eratic at high speeds.
|
||||
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
|
||||
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
|
||||
* Body.bottom and Body.right are no longer rounded, so will give accurate sub-pixel values.
|
||||
* Fixed lots of documentation in the Emitter class.
|
||||
* The delta timer value used for physics calculations has had its cap limit modified from 1.0 to 0.05 in line with the core updates.
|
||||
* Phaser.Math.min enhanced so you can now pass in either an array of numbers or lots of numbers as parameters to get the lowest.
|
||||
* Phaser.Math.max added as the opposite of Math.min.
|
||||
* Phaser.Math.minProperty and maxProperty added. Like Math.min/max but can be given a property an an array or list of objects to inspect.
|
||||
* Added 'full' paramter to Body.reset, allowing you to control if motion or all data is reset or not.
|
||||
* Exposed Group.pivot and Sprite.pivot to allow you to directly set the pivot points for rotation.
|
||||
* Swapped to using the native and faster Array.isArray check.
|
||||
* Added callback context parameter to Tween.onUpdateCallback(callback, context) to avoid having to bind or create anonymous functions.
|
||||
* Updated TweenManager.removeAll so it flags all tweens as pendingDelete rather than nuking the array, to avoid tween callback array size errors (thanks DarkDev)
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Cache.getImageKeys returned __missing in the array, now excluded.
|
||||
* Fixed Group.scale so you can now scale a Group directly.
|
||||
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
||||
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
|
||||
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group has no children.
|
||||
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
|
||||
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
|
||||
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
|
||||
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
|
||||
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
|
||||
* RenderTexture now displays correctly in Canvas games.
|
||||
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
|
||||
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
|
||||
* Patched desyrel.xml so it doesn't contain any zero width/height characters, as they broke Firefox 25.
|
||||
* Cache.addSound now implements a locked attribute (thanks haden)
|
||||
* Sound now checks for CocoonJS during playback to avoid readyState clash (thanks haden)
|
||||
* Buttons now clear previously set frames correctly if you call setFrames.
|
||||
* Sounds will now loop correctly if they are paused and resumed (thanks haden)
|
||||
* InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not.
|
||||
* Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it.
|
||||
* Fixed WebGLRenderer updateGraphics bug (thanks theadam)
|
||||
* Removed duplicate Timer.create line (thanks hstolte)
|
||||
* Fixed issue with the camera being slightly out of sync with 'fixedToCamera' sprites.
|
||||
* 1px camera jitter issue fixed where map is same size, or smaller than the game size.
|
||||
|
||||
|
||||
Version 1.1.3 - "Arafel" - November 29th 2013
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: p
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 138, 15);
|
||||
game.load.spritesheet('phaser', 'assets/tests/tween/phaser.png', 70, 90);
|
||||
game.load.spritesheet('phaser', 'assets/tests/tween/PHASER.png', 70, 90);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,53 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
game.load.image('sonic', 'assets/sprites/pangball.png');
|
||||
game.load.image('ball', 'assets/sprites/pangball.png');
|
||||
|
||||
}
|
||||
|
||||
var timer;
|
||||
var t;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#007236';
|
||||
game.stage.backgroundColor = '#6688ee';
|
||||
|
||||
t = game.time.create(false);
|
||||
|
||||
t.repeat(Phaser.Timer.SECOND * 2, 10, createBall, this);
|
||||
t.repeat(Phaser.Timer.SECOND * 3, 10, createBall, this);
|
||||
|
||||
// Every second we will call the addSprite function. This will happen 10 times and then stop.
|
||||
// The final parameter is the one that will be sent to the addSprite function and in this case is the sprite key.
|
||||
game.time.repeatEvent(Phaser.Timer.SECOND, 10, addSprite, this, 'mushroom');
|
||||
t.start();
|
||||
|
||||
// Every 1.5 seconds we will call the addSprite function. This will happen 5 times and then stop.
|
||||
game.time.repeatEvent(1500, 10, addSprite, this, 'sonic');
|
||||
game.input.onDown.add(killThem, this);
|
||||
|
||||
}
|
||||
|
||||
function addSprite(key) {
|
||||
function createBall() {
|
||||
|
||||
console.log(arguments);
|
||||
// A bouncey ball sprite just to visually see what's going on.
|
||||
var ball = game.add.sprite(game.world.randomX, 0, 'ball');
|
||||
|
||||
ball.body.gravity.y = 200;
|
||||
ball.body.bounce.y = 0.5;
|
||||
ball.body.collideWorldBounds = true;
|
||||
|
||||
console.log('nuked');
|
||||
game.time.removeAll();
|
||||
// t.removeAll();
|
||||
|
||||
game.add.sprite(game.world.randomX, game.world.randomY, key);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
function killThem() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderText(game.time._timer.ms, 32, 32);
|
||||
// game.debug.renderCameraInfo(game.camera, 32, 32);
|
||||
game.debug.renderText("Time until event: " + t.duration.toFixed(0), 32, 32);
|
||||
game.debug.renderText("Next tick: " + t.next.toFixed(0), 32, 64);
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Phaser",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
|
||||
"author": "Richard Davey",
|
||||
"logo": "https://raw.github.com/photonstorm/phaser/master/phaser-logo-small.png",
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overview
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for creating Flixel, from which both Phaser and my love of game development originate.
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."<br />
|
||||
* "If you want them to be more intelligent, read them more fairy tales."<br />
|
||||
* -- Albert Einstein
|
||||
*/
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
var Phaser = Phaser || {
|
||||
|
||||
VERSION: '<%= version %>',
|
||||
DEV_VERSION: '1.1.4',
|
||||
DEV_VERSION: '1.1.5',
|
||||
GAMES: [],
|
||||
|
||||
AUTO: 0,
|
||||
|
||||
@@ -980,7 +980,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.LEFT, this, body, response))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.right || this.touching.right)
|
||||
@@ -1004,6 +1004,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.left = true;
|
||||
body.touching.right = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1027,7 +1029,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.RIGHT, this, body))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.left || this.touching.left)
|
||||
@@ -1051,6 +1053,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.right = true;
|
||||
body.touching.left = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+57
-83
@@ -6,33 +6,7 @@
|
||||
// polygons using the Separating Axis Theorem.
|
||||
/** @preserve SAT.js - Version 0.2 - Copyright 2013 - Jim Riecken <jimr@jimr.ca> - released under the MIT License. https://github.com/jriecken/sat-js */
|
||||
|
||||
/*global define: false, module: false*/
|
||||
/*jshint shadow:true, sub:true, forin:true, noarg:true, noempty:true,
|
||||
eqeqeq:true, bitwise:true, strict:true, undef:true,
|
||||
curly:true, browser:true */
|
||||
|
||||
// Create a UMD wrapper for SAT. Works in:
|
||||
//
|
||||
// - Plain browser via global SAT variable
|
||||
// - AMD loader (like require.js)
|
||||
// - Node.js
|
||||
//
|
||||
// The quoted properties all over the place are used so that the Closure Compiler
|
||||
// does not mangle the exposed API in advanced mode.
|
||||
/**
|
||||
* @param {*} root - The global scope
|
||||
* @param {Function} factory - Factory that creates SAT module
|
||||
*/
|
||||
(function (root, factory) {
|
||||
"use strict";
|
||||
if (typeof define === 'function' && define['amd']) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module['exports'] = factory();
|
||||
} else {
|
||||
root['SAT'] = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
var SAT = (function () {
|
||||
"use strict";
|
||||
|
||||
var SAT = {};
|
||||
@@ -45,7 +19,7 @@
|
||||
|
||||
// Create a new Vector, optionally passing in the `x` and `y` coordinates. If
|
||||
// a coordinate is not specified, it will be set to `0`
|
||||
/**
|
||||
/**
|
||||
* @param {?number=} x The x position.
|
||||
* @param {?number=} y The y position.
|
||||
* @constructor
|
||||
@@ -118,7 +92,7 @@
|
||||
this['y'] = -this['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Normalize this vector. (make it have length of `1`)
|
||||
/**
|
||||
@@ -132,7 +106,7 @@
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Add another vector to this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -143,7 +117,7 @@
|
||||
this['y'] += other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Subtract another vector from this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -154,7 +128,7 @@
|
||||
this['y'] -= other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Scale this vector. An independant scaling factor can be provided
|
||||
// for each axis, or a single scaling factor that will scale both `x` and `y`.
|
||||
/**
|
||||
@@ -166,9 +140,9 @@
|
||||
Vector.prototype['scale'] = Vector.prototype.scale = function(x,y) {
|
||||
this['x'] *= x;
|
||||
this['y'] *= y || x;
|
||||
return this;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector on to another vector.
|
||||
/**
|
||||
* @param {Vector} other The vector to project onto.
|
||||
@@ -180,7 +154,7 @@
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector onto a vector of unit length. This is slightly more efficient
|
||||
// than `project` when dealing with unit vectors.
|
||||
/**
|
||||
@@ -193,7 +167,7 @@
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis.
|
||||
/**
|
||||
* @param {Vector} axis The vector representing the axis.
|
||||
@@ -207,7 +181,7 @@
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis (represented by a unit vector). This is
|
||||
// slightly more efficient than `reflect` when dealing with an axis that is a unit vector.
|
||||
/**
|
||||
@@ -222,7 +196,7 @@
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Get the dot product of this vector and another.
|
||||
/**
|
||||
* @param {Vector} other The vector to dot this one against.
|
||||
@@ -231,7 +205,7 @@
|
||||
Vector.prototype['dot'] = Vector.prototype.dot = function(other) {
|
||||
return this['x'] * other['x'] + this['y'] * other['y'];
|
||||
};
|
||||
|
||||
|
||||
// Get the squared length of this vector.
|
||||
/**
|
||||
* @return {number} The length^2 of this vector.
|
||||
@@ -239,7 +213,7 @@
|
||||
Vector.prototype['len2'] = Vector.prototype.len2 = function() {
|
||||
return this.dot(this);
|
||||
};
|
||||
|
||||
|
||||
// Get the length of this vector.
|
||||
/**
|
||||
* @return {number} The length of this vector.
|
||||
@@ -247,7 +221,7 @@
|
||||
Vector.prototype['len'] = Vector.prototype.len = function() {
|
||||
return Math.sqrt(this.len2());
|
||||
};
|
||||
|
||||
|
||||
// ## Circle
|
||||
//
|
||||
// Represents a circle with a position and a radius.
|
||||
@@ -290,7 +264,7 @@
|
||||
this.recalc();
|
||||
}
|
||||
SAT['Polygon'] = Polygon;
|
||||
|
||||
|
||||
// Recalculates the edges and normals of the polygon. This **must** be called
|
||||
// if the `points` array is modified at all and the edges or normals are to be
|
||||
// accessed.
|
||||
@@ -309,7 +283,7 @@
|
||||
var points = this['points'];
|
||||
var len = points.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var p1 = points[i];
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vector().copy(p2).sub(p1);
|
||||
var n = new Vector().copy(e).perp().normalize();
|
||||
@@ -418,11 +392,11 @@
|
||||
var w = this['w'];
|
||||
var h = this['h'];
|
||||
return new Polygon(new Vector(pos['x'], pos['y']), [
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(w,h), new Vector(0,h)
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
// ## Response
|
||||
//
|
||||
// An object representing the result of an intersection. Contains:
|
||||
@@ -433,7 +407,7 @@
|
||||
// - Whether the first object is entirely inside the second, and vice versa.
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
*/
|
||||
function Response() {
|
||||
this['a'] = null;
|
||||
this['b'] = null;
|
||||
@@ -465,7 +439,7 @@
|
||||
*/
|
||||
var T_VECTORS = [];
|
||||
for (var i = 0; i < 10; i++) { T_VECTORS.push(new Vector()); }
|
||||
|
||||
|
||||
// A pool of arrays of numbers used in calculations to avoid allocating
|
||||
// memory.
|
||||
/**
|
||||
@@ -498,7 +472,7 @@
|
||||
}
|
||||
result[0] = min; result[1] = max;
|
||||
}
|
||||
|
||||
|
||||
// Check whether two convex polygons are separated by the specified
|
||||
// axis (must be a unit vector).
|
||||
/**
|
||||
@@ -528,8 +502,8 @@
|
||||
rangeB[1] += projectedOffset;
|
||||
// Check if there is a gap. If there is, this is a separating axis and we can stop
|
||||
if (rangeA[0] > rangeB[1] || rangeB[0] > rangeA[1]) {
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return true;
|
||||
}
|
||||
@@ -540,7 +514,7 @@
|
||||
if (rangeA[0] < rangeB[0]) {
|
||||
response['aInB'] = false;
|
||||
// A ends before B does. We have to pull A out of B
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
overlap = rangeA[1] - rangeB[0];
|
||||
response['bInA'] = false;
|
||||
// B is fully inside A. Pick the shortest way out.
|
||||
@@ -553,7 +527,7 @@
|
||||
} else {
|
||||
response['bInA'] = false;
|
||||
// B ends before A ends. We have to push A out of B
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
overlap = rangeA[0] - rangeB[1];
|
||||
response['aInB'] = false;
|
||||
// A is fully inside B. Pick the shortest way out.
|
||||
@@ -571,14 +545,14 @@
|
||||
if (overlap < 0) {
|
||||
response['overlapN'].reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Calculates which Vornoi region a point is on a line segment.
|
||||
// It is assumed that both the line and the point are relative to `(0,0)`
|
||||
//
|
||||
@@ -588,8 +562,8 @@
|
||||
/**
|
||||
* @param {Vector} line The line segment.
|
||||
* @param {Vector} point The point.
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
||||
*/
|
||||
function vornoiRegion(line, point) {
|
||||
@@ -617,7 +591,7 @@
|
||||
* @const
|
||||
*/
|
||||
var RIGHT_VORNOI_REGION = 1;
|
||||
|
||||
|
||||
// ## Collision Tests
|
||||
|
||||
// Check if two circles collide.
|
||||
@@ -626,7 +600,7 @@
|
||||
* @param {Circle} b The second circle.
|
||||
* @param {Response=} response Response object (optional) that will be populated if
|
||||
* the circles intersect.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
*/
|
||||
function testCircleCircle(a, b, response) {
|
||||
// Check if the distance between the centers of the two
|
||||
@@ -641,7 +615,7 @@
|
||||
return false;
|
||||
}
|
||||
// They intersect. If we're calculating a response, calculate the overlap.
|
||||
if (response) {
|
||||
if (response) {
|
||||
var dist = Math.sqrt(distanceSq);
|
||||
response['a'] = a;
|
||||
response['b'] = b;
|
||||
@@ -655,7 +629,7 @@
|
||||
return true;
|
||||
}
|
||||
SAT['testCircleCircle'] = testCircleCircle;
|
||||
|
||||
|
||||
// Check if a polygon and a circle collide.
|
||||
/**
|
||||
* @param {Polygon} polygon The polygon.
|
||||
@@ -673,30 +647,30 @@
|
||||
var len = points.length;
|
||||
var edge = T_VECTORS.pop();
|
||||
var point = T_VECTORS.pop();
|
||||
|
||||
|
||||
// For each edge in the polygon:
|
||||
for (var i = 0; i < len; i++) {
|
||||
var next = i === len - 1 ? 0 : i + 1;
|
||||
var prev = i === 0 ? len - 1 : i - 1;
|
||||
var overlap = 0;
|
||||
var overlapN = null;
|
||||
|
||||
|
||||
// Get the edge.
|
||||
edge.copy(polygon['edges'][i]);
|
||||
// Calculate the center of the circle relative to the starting point of the edge.
|
||||
point.copy(circlePos).sub(points[i]);
|
||||
|
||||
|
||||
// If the distance between the center of the circle and the point
|
||||
// is bigger than the radius, the polygon is definitely not fully in
|
||||
// the circle.
|
||||
if (response && point.len2() > radius2) {
|
||||
response['aInB'] = false;
|
||||
}
|
||||
|
||||
|
||||
// Calculate which Vornoi region the center of the circle is in.
|
||||
var region = vornoiRegion(edge, point);
|
||||
// If it's the left region:
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
// We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge.
|
||||
edge.copy(polygon['edges'][prev]);
|
||||
// Calculate the center of the circle relative the starting point of the previous edge
|
||||
@@ -707,9 +681,9 @@
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point2);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -732,10 +706,10 @@
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
return false;
|
||||
} else if (response) {
|
||||
// It intersects, calculate the overlap.
|
||||
response['bInA'] = false;
|
||||
@@ -748,15 +722,15 @@
|
||||
// Need to check if the circle is intersecting the edge,
|
||||
// Change the edge into its "edge normal".
|
||||
var normal = edge.perp().normalize();
|
||||
// Find the perpendicular distance between the center of the
|
||||
// Find the perpendicular distance between the center of the
|
||||
// circle and the edge.
|
||||
var dist = point.dot(normal);
|
||||
var distAbs = Math.abs(dist);
|
||||
// If the circle is on the outside of the edge, there is no intersection.
|
||||
if (dist > 0 && distAbs > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -770,28 +744,28 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
// (overlapN may be null if the circle was in the wrong Vornoi region).
|
||||
if (overlapN && response && Math.abs(overlap) < Math.abs(response['overlap'])) {
|
||||
response['overlap'] = overlap;
|
||||
response['overlapN'].copy(overlapN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate the final overlap vector - based on the smallest overlap.
|
||||
if (response) {
|
||||
response['a'] = polygon;
|
||||
response['b'] = circle;
|
||||
response['overlapV'].copy(response['overlapN']).scale(response['overlap']);
|
||||
}
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return true;
|
||||
}
|
||||
SAT['testPolygonCircle'] = testPolygonCircle;
|
||||
|
||||
|
||||
// Check if a circle and a polygon collide.
|
||||
//
|
||||
// **NOTE:** This is slightly less efficient than polygonCircle as it just
|
||||
@@ -820,7 +794,7 @@
|
||||
return result;
|
||||
}
|
||||
SAT['testCirclePolygon'] = testCirclePolygon;
|
||||
|
||||
|
||||
// Checks whether polygons collide.
|
||||
/**
|
||||
* @param {Polygon} a The first polygon.
|
||||
@@ -859,4 +833,4 @@
|
||||
SAT['testPolygonPolygon'] = testPolygonPolygon;
|
||||
|
||||
return SAT;
|
||||
}));
|
||||
})();
|
||||
|
||||
@@ -918,8 +918,8 @@ Phaser.Tilemap.prototype = {
|
||||
}
|
||||
|
||||
// Find out the difference between tileblock[1].x/y and x/y and use it as an offset, as it's the top left of the block to paste
|
||||
var diffX = tileblock[1].x - x;
|
||||
var diffY = tileblock[1].y - y;
|
||||
var diffX = x - tileblock[1].x;
|
||||
var diffY = y - tileblock[1].y;
|
||||
|
||||
for (var i = 1; i < tileblock.length; i++)
|
||||
{
|
||||
|
||||
+33
-11
@@ -245,7 +245,7 @@ Phaser.Timer.prototype = {
|
||||
{
|
||||
if (this.events[i] === event)
|
||||
{
|
||||
this.events.splice(i, 1);
|
||||
this.events[i].pendingDelete = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -308,6 +308,21 @@ Phaser.Timer.prototype = {
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
this._i = 0;
|
||||
|
||||
while (this._i < this._len)
|
||||
{
|
||||
if (this.events[this._i].pendingDelete)
|
||||
{
|
||||
this.events.splice(this._i, 1);
|
||||
this._len--;
|
||||
}
|
||||
|
||||
this._i++;
|
||||
}
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
if (this.running && this._now >= this.nextTick && this._len > 0)
|
||||
{
|
||||
this._i = 0;
|
||||
@@ -371,9 +386,12 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
pause: function () {
|
||||
|
||||
this._pauseStarted = this.game.time.now;
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this._pauseStarted = this.game.time.now;
|
||||
|
||||
this.paused = true;
|
||||
this.paused = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -383,17 +401,20 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
resume: function () {
|
||||
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -405,6 +426,7 @@ Phaser.Timer.prototype = {
|
||||
this.onComplete.removeAll();
|
||||
this.running = false;
|
||||
this.events = [];
|
||||
this._i = this._len;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,12 @@ Phaser.TimerEvent = function (timer, delay, tick, repeatCount, loop, callback, c
|
||||
*/
|
||||
this.args = args;
|
||||
|
||||
/**
|
||||
* @property {boolean} pendingDelete - A flag that controls if the TimerEvent is pending deletion.
|
||||
* @protected
|
||||
*/
|
||||
this.pendingDelete = false;
|
||||
|
||||
};
|
||||
|
||||
Phaser.TimerEvent.prototype.constructor = Phaser.TimerEvent;
|
||||
|
||||
+3
-3
@@ -38,9 +38,9 @@ Phaser.Utils = {
|
||||
* dir = 1 (left), 2 (right), 3 (both)
|
||||
* @method Phaser.Utils.pad
|
||||
* @param {string} str - The target string.
|
||||
* @param {number} len - Description.
|
||||
* @param {number} pad - the string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @param {number} len - The number of characters to be added.
|
||||
* @param {number} pad - The string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] The direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @return {string} The padded string
|
||||
*/
|
||||
pad: function (str, len, pad, dir) {
|
||||
|
||||
Reference in New Issue
Block a user