mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
825d7d8a76
97 changed files with 2599 additions and 858 deletions
86
CHANGELOG.md
86
CHANGELOG.md
|
@ -19,6 +19,12 @@ being passed to the simulation. The default value is 1 to remain consistent with
|
|||
* HTML5AudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
|
||||
* HTML5AudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
|
||||
* HTML5AudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
|
||||
* BitmapText has a new property `letterSpacing` which accepts a positive or negative number to add / reduce spacing between characters (thanks @wtravO)
|
||||
* Matter Physics has two new debug properties: `debugShowJoint` and `debugJointColor`. If defined they will display joints in Matter bodies during the postUpdate debug phase (only if debug is enabled) (thanks @OmarShehata)
|
||||
* You can now pass a Sprite Sheet or Canvas as the Texture key to `Tilemap.addTileset` and it will work in WebGL, where-as before it would display a corrupted tilemap. Fix #3407 (thanks @Zykino)
|
||||
* Graphics.slice allows you to easily draw a Pacman, or slice of pie shape to a Graphics object.
|
||||
* List.addCallback is a new optional callback that is invoked every time a new child is added to the List. You can use this to have a callback fire when children are added to the Display List.
|
||||
* List.removeCallback is a new optional callback that is invoked every time a new child is removed from the List. You can use this to have a callback fire when children are removed from the Display List.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
@ -27,8 +33,20 @@ being passed to the simulation. The default value is 1 to remain consistent with
|
|||
* PathFollower.start has been renamed to `startFollow`, but PathFollower.setPath was still using `PathFollower.start` (thanks @samid737)
|
||||
* BaseSoundManager.rate and BaseSoundManager.detune would incorrectly called `setRate` on its sounds, instead of `calculateRate`.
|
||||
* The Gamepad Axis `getValue` method now correctly applies the threshold and zeroes out the returned value.
|
||||
* Tween.Restart handles removed tweens properly and readds them back into the
|
||||
active queue for the TweenManager
|
||||
* The HueToComponent module was not correctly exporting itself. Fix #3482 (thanks @jdotrjs)
|
||||
* Matter.World was using `setZ` instead of `setDepth` for the Debug Graphics Layer, causing it to appear behind objects in some display lists.
|
||||
* Game.destroy now checks to see if the `renderer` exists before calling destroy on it. Fix #3498 (thanks @Huararanga)
|
||||
* Keyboard.JustDown and Keyboard.JustUp were being reset too early, causing them to fail when called in `update` loops. Fix #3490 (thanks @belen-albeza)
|
||||
* RenderTexture.destroy no longer throws an error when called. Fix #3475 (thanks @kuoruan)
|
||||
* The WebGL TileSprite batch now modulates the tilePosition to avoid large values being passed into the UV data, fixing corruption when scrolling TileSprites over a long period of time. Fix #3402 (thanks @vinerz @FrancescoNegri)
|
||||
* LineCurve.getResolution was missing the `divisions` argument and always returning 1, which made it fail when used as part of a Path. It now defaults to return 1 unless specified otherwise (thanks _ok)
|
||||
* A Game Object enabled for drag would no longer fire over and out events after being dragged, now it does (thanks @jmcriat)
|
||||
* Line.getPointA and Line.getPointB incorrectly set the values into the Vector2 (thanks @Tomas2h)
|
||||
* DynamicTilemapLayer now uses the ComputedSize component, which stops it breaking if you call `setDisplaySize` (thanks Babsobar)
|
||||
* StaticTilemapLayer now uses the ComputedSize component, which stops it breaking if you call `setDisplaySize` (thanks Babsobar)
|
||||
* CanvasPool.first always returned `null`, and now returns the first available Canvas. Fix #3520 (thanks @mchiasson)
|
||||
* When starting a new Scene with an optional `data` argument it wouldn't get passed through if the Scene was not yet available (i.e. the game had not fully booted). The data is now passed to the Scene `init` method and stored in the Scene Settings data property. Fix #3363 (thanks @pixelhijack)
|
||||
* Tween.Restart handles removed tweens properly and readds them back into the active queue for the TweenManager (thanks @wtravO)
|
||||
|
||||
### Updates
|
||||
|
||||
|
@ -40,8 +58,70 @@ active queue for the TweenManager
|
|||
* The ComputedSize Component now has `setSize` and `setDisplaySize` methods. This component is used for Game Objects that have a non-texture based size.
|
||||
* The GamepadManager now extends EventEmitter directly, just like the KeyboardManager does.
|
||||
* The Gamepad Axis threshold has been increased from 0.05 to 0.1.
|
||||
* Utils.Array.FindClosestInSorted has a new optional argument `key` which will allow you to scan a top-level property of any object in the given sorted array and get the closest match to it.
|
||||
* Vector2.setTo is a method alias for Vector2.set allowing it to be used inter-changeably with Geom.Point.
|
||||
* List.add can now take an array or a single child. If an array is given it's passed over to List.addMultiple.
|
||||
* List.add has a new optional argument `skipCallback`.
|
||||
* List.addAt has a new optional argument `skipCallback`.
|
||||
* List.addMultiple has a new optional argument `skipCallback`.
|
||||
* List.remove has a new optional argument `skipCallback`.
|
||||
* List.removeAt has a new optional argument `skipCallback`.
|
||||
* List.removeBetween has a new optional argument `skipCallback`.
|
||||
* List.removeAll has a new optional argument `skipCallback`.
|
||||
|
||||
Also, my thanks to the following for helping with the Phaser 3 Examples, either by reporting errors or fixing them: @gabegordon @melissaelopez @samid737 @nbs @tgrajewski @pagesrichie @hexus
|
||||
### Animation System Updates
|
||||
|
||||
We have refactored the Animation API to make it more consistent with the rest of Phaser 3 and to fix some issues. All of the following changes apply to the Animation Component:
|
||||
|
||||
* Animation durations, delays and repeatDelays are all now specified in milliseconds, not seconds like before. This makes them consistent with Tweens, Sounds and other parts of v3. You can still use the `frameRate` property to set the speed of an animation in frames per second.
|
||||
* All of the Animation callbacks have been removed, including `onStart`, `onRepeat`, `onUpdate` and `onComplete` and the corresponding params arrays like `onStartParams` and the property `callbackScope`. The reason for this is that they were all set on a global level, meaning that if you had 100 Sprites sharing the same animation, it was impossible to set the callbacks to fire for just one of those Sprites, but instead they would fire for all 100 and it was up to you to figure out which Sprite you wanted to update. Instead of callbacks animations now dispatch events on the Game Objects in which they are running. This means you can now do `sprite.on('animationstart')` and it will be invoked at the same point the old `onStart` callback would have been. The new events are: `animationstart`, `animtionrepeat`, `animationupdate` and `animationcomplete`. They're all dispatched from the Game Object that has the animation playing, not from the animation itself. This allows you far more control over what happens in the callbacks and we believe generally makes them more useful.
|
||||
* The AnimationFrame.onUpdate callback has been removed. You can now use the `animationupdate` event dispatched from the Game Object itself and check the 2nd argument, which is the animation frame.
|
||||
* Animation.stopAfterDelay is a new method that will stop a Sprites animation after the given time in ms.
|
||||
* Animation.stopOnRepeat is a new method that will stop a Sprites animation when it goes to repeat.
|
||||
* Animation.stopOnFrame is a new method that will stop a Sprites animation when it sets the given frame.
|
||||
* Animation.stop no longer has the `dispatchCallbacks` argument, because it dispatches an event which you can choose to ignore.
|
||||
* `delay` method has been removed.
|
||||
* `setDelay` allows you to define the delay before playback begins.
|
||||
* `getDelay` returns the animation playback delay value.
|
||||
* `delayedPlay` now returns the parent Game Object instead of the component.
|
||||
* `load` now returns the parent Game Object instead of the component.
|
||||
* `pause` now returns the parent Game Object instead of the component.
|
||||
* `resume` now returns the parent Game Object instead of the component.
|
||||
* `isPaused` returns a boolean indicating the paused state of the animation.
|
||||
* `paused` method has been removed.
|
||||
* `play` now returns the parent Game Object instead of the component.
|
||||
* `progress` method has been removed.
|
||||
* `getProgress` returns the animation progress value.
|
||||
* `setProgress` lets you jump the animation to a specific progress point.
|
||||
* `repeat` method has been removed.
|
||||
* `getRepeat` returns the animation repeat value.
|
||||
* `setRepeat` sets the number of times the current animation will repeat.
|
||||
* `repeatDelay` method has been removed.
|
||||
* `getRepeatDelay` returns the animation repeat delay value.
|
||||
* `setRepeatDelay` sets the delay time between each repeat.
|
||||
* `restart` now returns the parent Game Object instead of the component.
|
||||
* `stop` now returns the parent Game Object instead of the component.
|
||||
* `timeScale` method has been removed.
|
||||
* `getTimeScale` returns the animation time scale value.
|
||||
* `setTimeScale` sets the time scale value.
|
||||
* `totalFrames` method has been removed.
|
||||
* `getTotalFrames` returns the total number of frames in the animation.
|
||||
* `totalProgres` method has been removed as it did nothing and was mis-spelt.
|
||||
* `yoyo` method has been removed.
|
||||
* `getYoyo` returns if the animation will yoyo or not.
|
||||
* `setYoyo` sets if the animation will yoyo or not.
|
||||
* `updateFrame` will now call `setSizeToFrame` on the Game Object, which will adjust the Game Objects `width` and `height` properties to match the frame size. Fix #3473 (thanks @wtravO @jp-gc)
|
||||
* `updateFrame` now supports animation frames with custom pivot points and injects these into the Game Object origin.
|
||||
* `destroy` now removes events, references to the Animation Manager and parent Game Object, clears the current animation and frame and empties internal arrays.
|
||||
* Changing the `yoyo` property on an Animation Component would have no effect as it only ever checked the global property, it now checks the local one properly allowing you to specify a `yoyo` on a per Game Object basis.
|
||||
* Animation.destroy now properly clears the global animation object.
|
||||
* Animation.getFrameByProgress will return the Animation Frame that is closest to the given progress value. For example, in a 5 frame animation calling this method with a value of 0.5 would return the middle frame.
|
||||
|
||||
### Examples, Documentation and TypeScript
|
||||
|
||||
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
|
||||
|
||||
@gabegordon @melissaelopez @samid737 @nbs @tgrajewski @pagesrichie @hexus @mbrickn @erd0s @icbat @Matthew-Herman @ampled @mkimmet @PaNaVTEC
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ Extra special thanks to our top-tier sponsors: [Orange Games](http://orangegames
|
|||
|
||||
Every week we publish the [Phaser World](https://phaser.io/community/newsletter) newsletter. It's packed full of the latest Phaser games, tutorials, videos, meet-ups, talks, and more. The newsletter also contains our weekly Development Progress updates which let you know about the new features we're working on.
|
||||
|
||||
Over 100 previous editions can be found on our [Back Issues](http://phaser.io/community/backissues) page.
|
||||
Over 100 previous editions can be found on our [Back Issues](https://phaser.io/community/backissues) page.
|
||||
|
||||
![Download Phaser](https://phaser.io/images/github/div-download.png "Download Phaser")
|
||||
<a name="download"></a>
|
||||
|
@ -93,7 +93,7 @@ npm install phaser
|
|||
|
||||
[![](https://data.jsdelivr.com/v1/package/gh/photonstorm/phaser/badge)](https://www.jsdelivr.com/package/gh/photonstorm/phaser)
|
||||
|
||||
[Phaser is on jsDelivr](http://www.jsdelivr.com/projects/phaser) which is a "super-fast CDN for developers". Include the following in your html:
|
||||
[Phaser is on jsDelivr](https://www.jsdelivr.com/projects/phaser) which is a "super-fast CDN for developers". Include the following in your html:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.3.0/dist/phaser.js"></script>
|
||||
|
@ -137,7 +137,7 @@ Also, please subscribe to the [Phaser World](https://phaser.io/community/newslet
|
|||
|
||||
### Source Code Examples
|
||||
|
||||
During our development of Phaser 3, we created hundreds of examples with the full source code and assets. Until these examples are fully integrated into the Phaser website, you can browse them on [Phaser 3 Labs](http://labs.phaser.io), or clone the [examples repo][examples]. Note: Not all examples work, sorry! We're tidying them up as fast as we can.
|
||||
During our development of Phaser 3, we created hundreds of examples with the full source code and assets. Until these examples are fully integrated into the Phaser website, you can browse them on [Phaser 3 Labs](https://labs.phaser.io), or clone the [examples repo][examples]. Note: Not all examples work, sorry! We're tidying them up as fast as we can.
|
||||
|
||||
### Create Your First Phaser 3 Example
|
||||
|
||||
|
@ -147,7 +147,7 @@ Create an `index.html` page locally and paste the following code into it:
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://labs.phaser.io/build/phaser-arcade-physics.min.js"></script>
|
||||
<script src="https://labs.phaser.io/build/phaser-arcade-physics.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
@ -8,10 +8,11 @@ var RotateAroundDistance = require('../math/RotateAroundDistance');
|
|||
var DistanceBetween = require('../math/distance/DistanceBetween');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Rotates each item around the given point by the given angle.
|
||||
*
|
||||
* @function Phaser.Actions.RotateAround
|
||||
* @since 3.0.0
|
||||
* @see Phaser.Math.RotateAroundDistance
|
||||
*
|
||||
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
|
||||
*
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
var ArrayShuffle = require('../utils/array/Shuffle');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Shuffles the array in place. The shuffled array is both modified and returned.
|
||||
*
|
||||
* @function Phaser.Actions.Shuffle
|
||||
* @since 3.0.0
|
||||
* @see Phaser.Utils.Array.Shuffle
|
||||
*
|
||||
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
|
||||
*
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Clamp = require('../math/Clamp');
|
||||
var Class = require('../utils/Class');
|
||||
var FindClosestInSorted = require('../utils/array/FindClosestInSorted');
|
||||
var Frame = require('./AnimationFrame');
|
||||
var GetValue = require('../utils/object/GetValue');
|
||||
|
||||
|
@ -15,11 +17,11 @@ var GetValue = require('../utils/object/GetValue');
|
|||
* @property {string} type - A frame based animation (as opposed to a bone based animation)
|
||||
* @property {JSONAnimationFrame[]} frames - [description]
|
||||
* @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null)
|
||||
* @property {integer} duration - How long the animation should play for.
|
||||
* @property {integer} duration - How long the animation should play for in milliseconds. If not given its derived from frameRate.
|
||||
* @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway?
|
||||
* @property {integer} delay - Delay before starting playback (in seconds)
|
||||
* @property {integer} delay - Delay before starting playback. Value given in milliseconds.
|
||||
* @property {integer} repeat - Number of times to repeat the animation (-1 for infinity)
|
||||
* @property {integer} repeatDelay - Delay before the repeat starts (in seconds)
|
||||
* @property {integer} repeatDelay - Delay before the animation repeats. Value given in milliseconds.
|
||||
* @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating?
|
||||
* @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play?
|
||||
* @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes?
|
||||
|
@ -32,7 +34,6 @@ var GetValue = require('../utils/object/GetValue');
|
|||
* @property {(string|number)} frame - [description]
|
||||
* @property {float} [duration=0] - [description]
|
||||
* @property {boolean} [visible] - [description]
|
||||
* @property {function} [onUpdate] - [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -41,23 +42,14 @@ var GetValue = require('../utils/object/GetValue');
|
|||
* @property {AnimationFrameConfig[]} [frames] - [description]
|
||||
* @property {string} [defaultTextureKey=null] - [description]
|
||||
* @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null)
|
||||
* @property {integer} [duration] - How long the animation should play for.
|
||||
* @property {integer} [duration] - How long the animation should play for in milliseconds. If not given its derived from frameRate.
|
||||
* @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway?
|
||||
* @property {integer} [delay=0] - Delay before starting playback (in seconds)
|
||||
* @property {integer} [delay=0] - Delay before starting playback. Value given in milliseconds.
|
||||
* @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity)
|
||||
* @property {integer} [repeatDelay=0] - Delay before the repeat starts (in seconds)
|
||||
* @property {integer} [repeatDelay=0] - Delay before the animation repeats. Value given in milliseconds.
|
||||
* @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating?
|
||||
* @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play?
|
||||
* @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes?
|
||||
* @property {*} [callbackScope] - [description]
|
||||
* @property {(false|function)} [onStart=false] - [description]
|
||||
* @property {Array.<*>} [onStartParams] - [description]
|
||||
* @property {(false|function)} [onRepeat=false] - [description]
|
||||
* @property {Array.<*>} [onRepeatParams] - [description]
|
||||
* @property {(false|function)} [onUpdate=false] - [description]
|
||||
* @property {Array.<*>} [onUpdateParams] - [description]
|
||||
* @property {(false|function)} [onComplete=false] - [description]
|
||||
* @property {Array.<*>} [onCompleteParams] - [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -137,8 +129,9 @@ var Animation = new Class({
|
|||
this.frameRate = GetValue(config, 'frameRate', null);
|
||||
|
||||
/**
|
||||
* How long the animation should play for.
|
||||
* If frameRate is set it overrides this value otherwise frameRate is derived from duration.
|
||||
* How long the animation should play for, in milliseconds.
|
||||
* If the `frameRate` property has been set then it overrides this value,
|
||||
* otherwise the `frameRate` is derived from `duration`.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#duration
|
||||
* @type {integer}
|
||||
|
@ -150,25 +143,25 @@ var Animation = new Class({
|
|||
{
|
||||
// No duration or frameRate given, use default frameRate of 24fps
|
||||
this.frameRate = 24;
|
||||
this.duration = this.frameRate / this.frames.length;
|
||||
this.duration = (this.frameRate / this.frames.length) * 1000;
|
||||
}
|
||||
else if (this.duration && this.frameRate === null)
|
||||
{
|
||||
// Duration given but no frameRate, so set the frameRate based on duration
|
||||
// I.e. 12 frames in the animation, duration = 4 (4000 ms)
|
||||
// So frameRate is 12 / 4 = 3 fps
|
||||
this.frameRate = this.frames.length / this.duration;
|
||||
// I.e. 12 frames in the animation, duration = 4000 ms
|
||||
// So frameRate is 12 / (4000 / 1000) = 3 fps
|
||||
this.frameRate = this.frames.length / (this.duration / 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// frameRate given, derive duration from it (even if duration also specified)
|
||||
// I.e. 15 frames in the animation, frameRate = 30 fps
|
||||
// So duration is 15 / 30 = 0.5 (half a second)
|
||||
this.duration = this.frames.length / this.frameRate;
|
||||
// So duration is 15 / 30 = 0.5 * 1000 (half a second, or 500ms)
|
||||
this.duration = (this.frames.length / this.frameRate) * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* ms per frame (without including frame specific modifiers)
|
||||
* How many ms per frame, not including frame specific modifiers.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#msPerFrame
|
||||
* @type {integer}
|
||||
|
@ -187,7 +180,7 @@ var Animation = new Class({
|
|||
this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true);
|
||||
|
||||
/**
|
||||
* Delay before starting playback (in seconds)
|
||||
* The delay in ms before the playback will begin.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#delay
|
||||
* @type {integer}
|
||||
|
@ -197,7 +190,7 @@ var Animation = new Class({
|
|||
this.delay = GetValue(config, 'delay', 0);
|
||||
|
||||
/**
|
||||
* Number of times to repeat the animation (-1 for infinity)
|
||||
* Number of times to repeat the animation. Set to -1 to repeat forever.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#repeat
|
||||
* @type {integer}
|
||||
|
@ -207,7 +200,7 @@ var Animation = new Class({
|
|||
this.repeat = GetValue(config, 'repeat', 0);
|
||||
|
||||
/**
|
||||
* Delay before the repeat starts (in seconds)
|
||||
* The delay in ms before the a repeat playthrough starts.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#repeatDelay
|
||||
* @type {integer}
|
||||
|
@ -247,89 +240,7 @@ var Animation = new Class({
|
|||
this.hideOnComplete = GetValue(config, 'hideOnComplete', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#callbackScope
|
||||
* @type {*}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.callbackScope = GetValue(config, 'callbackScope', this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onStart
|
||||
* @type {(false|function)}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onStart = GetValue(config, 'onStart', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onStartParams
|
||||
* @type {Array.<*>}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onStartParams = GetValue(config, 'onStartParams', []);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onRepeat
|
||||
* @type {(false|function)}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onRepeat = GetValue(config, 'onRepeat', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onRepeatParams
|
||||
* @type {Array.<*>}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onRepeatParams = GetValue(config, 'onRepeatParams', []);
|
||||
|
||||
/**
|
||||
* Called for EVERY frame of the animation.
|
||||
* See AnimationFrame.onUpdate for a frame specific callback.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onUpdate
|
||||
* @type {(false|function)}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onUpdate = GetValue(config, 'onUpdate', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onUpdateParams
|
||||
* @type {Array.<*>}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onUpdateParams = GetValue(config, 'onUpdateParams', []);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onComplete
|
||||
* @type {(false|function)}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onComplete = GetValue(config, 'onComplete', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Animations.Animation#onCompleteParams
|
||||
* @type {Array.<*>}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onCompleteParams = GetValue(config, 'onCompleteParams', []);
|
||||
|
||||
/**
|
||||
* Global pause, effects all Game Objects using this Animation instance
|
||||
* Global pause. All Game Objects using this Animation instance are impacted by this property.
|
||||
*
|
||||
* @name Phaser.Animations.Animation#paused
|
||||
* @type {boolean}
|
||||
|
@ -338,14 +249,12 @@ var Animation = new Class({
|
|||
*/
|
||||
this.paused = false;
|
||||
|
||||
this.manager.on('pauseall', this.pause.bind(this));
|
||||
this.manager.on('resumeall', this.resume.bind(this));
|
||||
this.manager.on('pauseall', this.pause, this);
|
||||
this.manager.on('resumeall', this.resume, this);
|
||||
},
|
||||
|
||||
// Add frames to the end of the animation
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Add frames to the end of the animation.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#addFrame
|
||||
* @since 3.0.0
|
||||
|
@ -359,10 +268,8 @@ var Animation = new Class({
|
|||
return this.addFrameAt(this.frames.length, config);
|
||||
},
|
||||
|
||||
// Add frame/s into the animation
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Add frame/s into the animation.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#addFrameAt
|
||||
* @since 3.0.0
|
||||
|
@ -401,24 +308,25 @@ var Animation = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Check if the given frame index is valid.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#checkFrame
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} index - [description]
|
||||
* @param {integer} index - The index to be checked.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} `true` if the index is valid, otherwise `false`.
|
||||
*/
|
||||
checkFrame: function (index)
|
||||
{
|
||||
return (index < this.frames.length);
|
||||
return (index >= 0 && index < this.frames.length);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Animations.Animation#completeAnimation
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.Animation} component - [description]
|
||||
|
@ -430,13 +338,14 @@ var Animation = new Class({
|
|||
component.parent.visible = false;
|
||||
}
|
||||
|
||||
component.stop(true);
|
||||
component.stop();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Animations.Animation#getFirstTick
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.Animation} component - [description]
|
||||
|
@ -452,7 +361,7 @@ var Animation = new Class({
|
|||
|
||||
if (includeDelay)
|
||||
{
|
||||
component.nextTick += (component._delay * 1000);
|
||||
component.nextTick += component._delay;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -460,6 +369,7 @@ var Animation = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @method Phaser.Animations.Animation#getFrameAt
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} index - [description]
|
||||
|
@ -533,7 +443,6 @@ var Animation = new Class({
|
|||
animationFrame = new Frame(key, frame, index, textureFrame);
|
||||
|
||||
animationFrame.duration = GetValue(item, 'duration', 0);
|
||||
animationFrame.onUpdate = GetValue(item, 'onUpdate', null);
|
||||
|
||||
animationFrame.isFirst = (!prev);
|
||||
|
||||
|
@ -594,9 +503,10 @@ var Animation = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Loads the Animation values into the Animation Component.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#load
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.Animation} component - [description]
|
||||
|
@ -613,22 +523,38 @@ var Animation = new Class({
|
|||
{
|
||||
component.currentAnim = this;
|
||||
|
||||
component._timeScale = 1;
|
||||
component.frameRate = this.frameRate;
|
||||
component.duration = this.duration;
|
||||
component.msPerFrame = this.msPerFrame;
|
||||
component.skipMissedFrames = this.skipMissedFrames;
|
||||
|
||||
component._timeScale = 1;
|
||||
component._delay = this.delay;
|
||||
component._repeat = this.repeat;
|
||||
component._repeatDelay = this.repeatDelay;
|
||||
component._yoyo = this.yoyo;
|
||||
component._callbackArgs[1] = this;
|
||||
component._updateParams = component._callbackArgs.concat(this.onUpdateParams);
|
||||
}
|
||||
|
||||
component.updateFrame(this.frames[startFrame]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the frame closest to the given progress value between 0 and 1.
|
||||
*
|
||||
* @method Phaser.Animations.Animation#getFrameByProgress
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {float} value - A value between 0 and 1.
|
||||
*
|
||||
* @return {Phaser.Animations.AnimationFrame} [description]
|
||||
*/
|
||||
getFrameByProgress: function (value)
|
||||
{
|
||||
value = Clamp(value, 0, 1);
|
||||
|
||||
return FindClosestInSorted(value, this.frames, 'progress');
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -648,7 +574,7 @@ var Animation = new Class({
|
|||
// We're at the end of the animation
|
||||
|
||||
// Yoyo? (happens before repeat)
|
||||
if (this.yoyo)
|
||||
if (component.yoyo)
|
||||
{
|
||||
component.forward = false;
|
||||
|
||||
|
@ -762,11 +688,16 @@ var Animation = new Class({
|
|||
*/
|
||||
repeatAnimation: function (component)
|
||||
{
|
||||
if (component._pendingStop === 2)
|
||||
{
|
||||
return this.completeAnimation(component);
|
||||
}
|
||||
|
||||
if (component._repeatDelay > 0 && component.pendingRepeat === false)
|
||||
{
|
||||
component.pendingRepeat = true;
|
||||
component.accumulator -= component.nextTick;
|
||||
component.nextTick += (component._repeatDelay * 1000);
|
||||
component.nextTick += component._repeatDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -776,13 +707,13 @@ var Animation = new Class({
|
|||
|
||||
component.updateFrame(component.currentFrame.nextFrame);
|
||||
|
||||
this.getNextTick(component);
|
||||
|
||||
component.pendingRepeat = false;
|
||||
|
||||
if (this.onRepeat)
|
||||
if (component.isPlaying)
|
||||
{
|
||||
this.onRepeat.apply(this.callbackScope, component._callbackArgs.concat(this.onRepeatParams));
|
||||
this.getNextTick(component);
|
||||
|
||||
component.pendingRepeat = false;
|
||||
|
||||
component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -924,7 +855,19 @@ var Animation = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
// TODO
|
||||
this.manager.off('pauseall', this.pause, this);
|
||||
this.manager.off('resumeall', this.resume, this);
|
||||
|
||||
this.manager.remove(this.key);
|
||||
|
||||
for (var i = 0; i < this.frames.length; i++)
|
||||
{
|
||||
this.frames[i].destroy();
|
||||
}
|
||||
|
||||
this.frames = [];
|
||||
|
||||
this.manager = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -142,16 +142,6 @@ var AnimationFrame = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
/**
|
||||
* A frame specific callback, invoked if this frame gets displayed and the callback is set.
|
||||
*
|
||||
* @name Phaser.Animations.AnimationFrame#onUpdate
|
||||
* @type {?function}
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onUpdate = null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -180,7 +170,6 @@ var AnimationFrame = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.frame = undefined;
|
||||
this.onUpdate = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -511,24 +511,28 @@ var AnimationManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes an array of Game Objects that have the Animation Component and then
|
||||
* starts the given animation playing on them, each one offset by the
|
||||
* `stagger` amount given to this method.
|
||||
*
|
||||
* @method Phaser.Animations.AnimationManager#staggerPlay
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {number} [stagger=0] - [description]
|
||||
* @param {string} key - The key of the animation to play on the Game Objects.
|
||||
* @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have the Animation Component.
|
||||
* @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by.
|
||||
*
|
||||
* @return {Phaser.Animations.AnimationManager} This Animation Manager.
|
||||
*/
|
||||
staggerPlay: function (key, child, stagger)
|
||||
staggerPlay: function (key, children, stagger)
|
||||
{
|
||||
if (stagger === undefined) { stagger = 0; }
|
||||
|
||||
if (!Array.isArray(child))
|
||||
if (!Array.isArray(children))
|
||||
{
|
||||
child = [ child ];
|
||||
children = [ children ];
|
||||
}
|
||||
|
||||
var anim = this.get(key);
|
||||
|
@ -538,9 +542,9 @@ var AnimationManager = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < child.length; i++)
|
||||
for (var i = 0; i < children.length; i++)
|
||||
{
|
||||
child[i].anims.delayedPlay(stagger * i, key);
|
||||
children[i].anims.delayedPlay(stagger * i, key);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -57,10 +57,10 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @property {number} [zoom=1] - [description]
|
||||
* @property {number} [resolution=1] - [description]
|
||||
* @property {number} [type=CONST.AUTO] - [description]
|
||||
* @property {*} [?parent=null] - [description]
|
||||
* @property {HTMLCanvasElement} [?canvas=null] - [description]
|
||||
* @property {string} [?canvasStyle=null] - [description]
|
||||
* @property {object} [?scene=null] - [description]
|
||||
* @property {*} [parent=null] - [description]
|
||||
* @property {HTMLCanvasElement} [canvas=null] - [description]
|
||||
* @property {string} [canvasStyle=null] - [description]
|
||||
* @property {object} [scene=null] - [description]
|
||||
* @property {string[]} [seed] - [description]
|
||||
* @property {string} [title=''] - [description]
|
||||
* @property {string} [url='http://phaser.io'] - [description]
|
||||
|
@ -69,17 +69,17 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @property {boolean} [input.keyboard=true] - [description]
|
||||
* @property {*} [input.keyboard.target=window] - [description]
|
||||
* @property {(boolean|object)} [input.mouse=true] - [description]
|
||||
* @property {*} [?input.mouse.target=null] - [description]
|
||||
* @property {*} [input.mouse.target=null] - [description]
|
||||
* @property {boolean} [input.touch=true] - [description]
|
||||
* @property {*} [?input.touch.target=null] - [description]
|
||||
* @property {boolean} [?input.touch.capture=true] - [description]
|
||||
* @property {*} [input.touch.target=null] - [description]
|
||||
* @property {boolean} [input.touch.capture=true] - [description]
|
||||
* @property {(boolean|object)} [input.gamepad=false] - [description]
|
||||
* @property {boolean} [disableContextMenu=false] - [description]
|
||||
* @property {(boolean|object)} [banner=false] - [description]
|
||||
* @property {boolean} [banner.hidePhaser=false] - [description]
|
||||
* @property {string} [banner.text='#ffffff'] - [description]
|
||||
* @property {string[]} [banner.background] - [description]
|
||||
* @property {FPSConfig} [?fps] - [description]
|
||||
* @property {FPSConfig} [fps] - [description]
|
||||
* @property {boolean} [antialias=true] - [description]
|
||||
* @property {boolean} [pixelArt=false] - [description]
|
||||
* @property {boolean} [autoResize=false] - [description]
|
||||
|
@ -91,13 +91,14 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @property {boolean} [failIfMajorPerformanceCaveat=false] - [description]
|
||||
* @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default"
|
||||
* @property {(string|number)} [backgroundColor=0x000000] - [description]
|
||||
* @property {object} [?callbacks] - [description]
|
||||
* @property {object} [callbacks] - [description]
|
||||
* @property {BootCallback} [callbacks.preBoot=NOOP] - [description]
|
||||
* @property {BootCallback} [callbacks.postBoot=NOOP] - [description]
|
||||
* @property {LoaderConfig} [?loader] - [description]
|
||||
* @property {object} [?images] - [description]
|
||||
* @property {LoaderConfig} [loader] - [description]
|
||||
* @property {object} [images] - [description]
|
||||
* @property {string} [images.default] - [description]
|
||||
* @property {string} [images.missing] - [description]
|
||||
* @property {object} [physics] - [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,7 +154,7 @@ var Game = new Class({
|
|||
this.cache = new CacheManager(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Data Manager
|
||||
*
|
||||
* @name Phaser.Game#registry
|
||||
* @type {Phaser.Data.DataManager}
|
||||
|
@ -538,7 +538,10 @@ var Game = new Class({
|
|||
|
||||
this.scene.destroy();
|
||||
|
||||
this.renderer.destroy();
|
||||
if (this.renderer)
|
||||
{
|
||||
this.renderer.destroy();
|
||||
}
|
||||
|
||||
this.events.emit('destroy');
|
||||
|
||||
|
@ -546,7 +549,7 @@ var Game = new Class({
|
|||
|
||||
this.onStepCallback = null;
|
||||
|
||||
if (removeCanvas)
|
||||
if (removeCanvas && this.canvas)
|
||||
{
|
||||
CanvasPool.remove(this.canvas);
|
||||
}
|
||||
|
|
11
src/cache/CacheManager.js
vendored
11
src/cache/CacheManager.js
vendored
|
@ -43,7 +43,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#binary
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.binary = new BaseCache();
|
||||
|
@ -54,7 +53,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#bitmapFont
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.bitmapFont = new BaseCache();
|
||||
|
@ -64,7 +62,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#json
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.json = new BaseCache();
|
||||
|
@ -74,7 +71,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#physics
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.physics = new BaseCache();
|
||||
|
@ -84,7 +80,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#shader
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.shader = new BaseCache();
|
||||
|
@ -94,7 +89,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#audio
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.audio = new BaseCache();
|
||||
|
@ -104,7 +98,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#text
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.text = new BaseCache();
|
||||
|
@ -114,7 +107,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#obj
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.obj = new BaseCache();
|
||||
|
@ -125,7 +117,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#tilemap
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.tilemap = new BaseCache();
|
||||
|
@ -135,7 +126,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#xml
|
||||
* @type {Phaser.Cache.BaseCache}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.xml = new BaseCache();
|
||||
|
@ -146,7 +136,6 @@ var CacheManager = new Class({
|
|||
*
|
||||
* @name Phaser.Cache.CacheManager#custom
|
||||
* @type {Object.<Phaser.Cache.BaseCache>}
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.custom = {};
|
||||
|
|
|
@ -958,7 +958,7 @@ var Camera = new Class({
|
|||
*/
|
||||
ignore: function (gameObjectOrArray)
|
||||
{
|
||||
if (gameObjectOrArray instanceof Array)
|
||||
if (Array.isArray(gameObjectOrArray))
|
||||
{
|
||||
for (var index = 0; index < gameObjectOrArray.length; ++index)
|
||||
{
|
||||
|
|
|
@ -107,11 +107,15 @@ var LineCurve = new Class({
|
|||
* @method Phaser.Curves.LineCurve#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @param {number} [divisions=1] - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getResolution: function ()
|
||||
getResolution: function (divisions)
|
||||
{
|
||||
return 1;
|
||||
if (divisions === undefined) { divisions = 1; }
|
||||
|
||||
return divisions;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,9 +9,9 @@ var Class = require('../utils/Class');
|
|||
/**
|
||||
* @callback DataEachCallback
|
||||
*
|
||||
* @param {*} parent - [description]
|
||||
* @param {string} key - [description]
|
||||
* @param {*} value - [description]
|
||||
* @param {*} parent - The parent object of the DataManager.
|
||||
* @param {string} key - The key of the value.
|
||||
* @param {*} value - The value.
|
||||
* @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data.
|
||||
*/
|
||||
|
||||
|
@ -26,8 +26,8 @@ var Class = require('../utils/Class');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {*} parent - [description]
|
||||
* @param {Phaser.Events.EventEmitter} eventEmitter - [description]
|
||||
* @param {object} parent - The object that this DataManager belongs to.
|
||||
* @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter.
|
||||
*/
|
||||
var DataManager = new Class({
|
||||
|
||||
|
@ -36,7 +36,7 @@ var DataManager = new Class({
|
|||
function DataManager (parent, eventEmitter)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The object that this DataManager belongs to.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#parent
|
||||
* @type {*}
|
||||
|
@ -45,7 +45,7 @@ var DataManager = new Class({
|
|||
this.parent = parent;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The DataManager's event emitter.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#events
|
||||
* @type {Phaser.Events.EventEmitter}
|
||||
|
@ -59,7 +59,7 @@ var DataManager = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The data list.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#list
|
||||
* @type {Object.<string, *>}
|
||||
|
@ -69,7 +69,10 @@ var DataManager = new Class({
|
|||
this.list = {};
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether setting data is blocked for this DataManager.
|
||||
*
|
||||
* Used temporarily to allow 'changedata' event listeners to prevent
|
||||
* specific data from being set.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#blockSet
|
||||
* @type {boolean}
|
||||
|
@ -79,7 +82,7 @@ var DataManager = new Class({
|
|||
this.blockSet = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether setting data is frozen for this DataManager.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#_frozen
|
||||
* @type {boolean}
|
||||
|
@ -98,9 +101,9 @@ var DataManager = new Class({
|
|||
* @method Phaser.Data.DataManager#get
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The key of the value to retrieve.
|
||||
*
|
||||
* @return {*} [description]
|
||||
* @return {*} The value belonging to the given key.
|
||||
*/
|
||||
get: function (key)
|
||||
{
|
||||
|
@ -108,12 +111,12 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieves all data values.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#getAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Object.<string, *>} [description]
|
||||
* @return {Object.<string, *>} All data values.
|
||||
*/
|
||||
getAll: function ()
|
||||
{
|
||||
|
@ -131,14 +134,14 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Queries the DataManager for the values of keys matching the given search string.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#query
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} search - [description]
|
||||
* @param {string} search - The search string.
|
||||
*
|
||||
* @return {Object.<string, *>} [description]
|
||||
* @return {Object.<string, *>} The values of the keys matching the search string.
|
||||
*/
|
||||
query: function (search)
|
||||
{
|
||||
|
@ -156,13 +159,15 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the value for the given key.
|
||||
*
|
||||
* Emits the 'changedata' and 'setdata' events.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#set
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {*} data - [description]
|
||||
* @param {string} key - The key to set the value for.
|
||||
* @param {*} data - The value to set.
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
|
@ -235,13 +240,13 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Merge the given data object into this DataManager's data object.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#merge
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Object.<string, *>} data - [description]
|
||||
* @param {boolean} overwrite - [description]
|
||||
* @param {Object.<string, *>} data - The data to merge.
|
||||
* @param {boolean} overwrite - Whether to overwrite existing data. Defaults to true.
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
|
@ -262,12 +267,12 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Remove the value for the given key.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The key to remove
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
|
@ -286,14 +291,14 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Gets the data associated with the given 'key', deletes it from this Data store, then returns it.
|
||||
* Retrieves the data associated with the given 'key', deletes it from this Data store, then returns it.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#pop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The key of the value to retrieve and delete.
|
||||
*
|
||||
* @return {*} [description]
|
||||
* @return {*} The value of the given key.
|
||||
*/
|
||||
pop: function (key)
|
||||
{
|
||||
|
@ -312,14 +317,14 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Determines whether the given key is set in this Data store.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#has
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The key to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the key is set.
|
||||
*/
|
||||
has: function (key)
|
||||
{
|
||||
|
@ -327,12 +332,12 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Freeze or unfreeze this Data store, to allow or prevent setting its values.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#setFreeze
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} value - [description]
|
||||
* @param {boolean} value - Whether to freeze the Data store.
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
|
@ -344,7 +349,7 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Delete all data in this Data store and unfreeze it.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#reset
|
||||
* @since 3.0.0
|
||||
|
@ -365,7 +370,7 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroy this data manager.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#destroy
|
||||
* @since 3.0.0
|
||||
|
@ -382,7 +387,7 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Freeze this Data component, so no changes can be written to it.
|
||||
* Freeze this Data component, so no values can be set.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#freeze
|
||||
* @type {boolean}
|
||||
|
|
|
@ -126,13 +126,14 @@ var CanvasPool = function ()
|
|||
{
|
||||
if (canvasType === undefined) { canvasType = CONST.CANVAS; }
|
||||
|
||||
pool.forEach(function (container)
|
||||
for (var i = 0, len = pool.length; i < len; i++)
|
||||
{
|
||||
var container = pool[i];
|
||||
if (!container.parent && container.type === canvasType)
|
||||
{
|
||||
return container;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -47,4 +47,4 @@ var HueToComponent = function (p, q, t)
|
|||
return p;
|
||||
};
|
||||
|
||||
module.export = HueToComponent;
|
||||
module.exports = HueToComponent;
|
||||
|
|
|
@ -115,7 +115,7 @@ var GeometryMask = new Class({
|
|||
|
||||
renderer.currentContext.save();
|
||||
|
||||
geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, null, true);
|
||||
geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, undefined, null, true);
|
||||
|
||||
renderer.currentContext.clip();
|
||||
},
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object.
|
||||
* @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object.
|
||||
* @param {boolean} [overflowHidden=true] - [description]
|
||||
* @param {boolean} [overflowHidden=true] - Whether or not to hide overflowing content inside the parent.
|
||||
*
|
||||
* @return {HTMLElement} The element that was added to the DOM.
|
||||
*/
|
||||
|
|
|
@ -94,6 +94,7 @@ var EventEmitter = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|symbol)} event - The event name.
|
||||
* @param {...*} [args] - Additional arguments that will be passed to the event handler.
|
||||
*
|
||||
* @return {boolean} `true` if the event had listeners, else `false`.
|
||||
*/
|
||||
|
|
|
@ -55,6 +55,15 @@ var GameObject = new Class({
|
|||
*/
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* The parent Container of this Game Object, if it has one.
|
||||
*
|
||||
* @name Phaser.GameObjects.GameObject#parentContainer
|
||||
* @type {Phaser.GameObjects.Container}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.parentContainer = null;
|
||||
|
||||
/**
|
||||
* The name of this Game Object.
|
||||
* Empty by default and never populated by Phaser, this is left for developers to use.
|
||||
|
@ -186,10 +195,11 @@ var GameObject = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Adds a DataManager to this object.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObject#setDataEnabled
|
||||
* @since 3.0.0
|
||||
* @see Phaser.Data.DataManager
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This GameObject.
|
||||
*/
|
||||
|
|
|
@ -26,6 +26,7 @@ var GetBitmapTextSize = function (src, round)
|
|||
|
||||
var chars = src.fontData.chars;
|
||||
var lineHeight = src.fontData.lineHeight;
|
||||
var letterSpacing = src.letterSpacing;
|
||||
|
||||
var xAdvance = 0;
|
||||
var yAdvance = 0;
|
||||
|
@ -98,7 +99,7 @@ var GetBitmapTextSize = function (src, round)
|
|||
bh = gh;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var text = src.text;
|
||||
var textLength = text.length;
|
||||
|
@ -89,6 +90,12 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
|
|||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
ctx.translate(src.x, src.y);
|
||||
|
||||
ctx.rotate(src.rotation);
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera)
|
||||
var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var text = bitmapText.text;
|
||||
var textLength = text.length;
|
||||
|
@ -30,7 +31,7 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolati
|
|||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchDynamicBitmapText(bitmapText, camera);
|
||||
this.pipeline.batchDynamicBitmapText(bitmapText, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = DynamicBitmapTextWebGLRenderer;
|
||||
|
|
|
@ -33,6 +33,7 @@ var Render = require('./BitmapTextRender');
|
|||
* @property {string} font - [description]
|
||||
* @property {string} text - [description]
|
||||
* @property {number} fontSize - [description]
|
||||
* @property {number} letterSpacing - Adds/Removes spacing between characters
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -129,6 +130,16 @@ var BitmapText = new Class({
|
|||
*/
|
||||
this.fontSize = size || this.fontData.size;
|
||||
|
||||
/**
|
||||
* Adds/Removes spacing between characters
|
||||
* Can be a negative or positive number
|
||||
*
|
||||
* @name Phaser.GameObjects.BitmapText#letterSpacing
|
||||
* @type {number}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.letterSpacing = 0;
|
||||
|
||||
this.setTexture(entry.texture, entry.frame);
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin(0, 0);
|
||||
|
@ -162,6 +173,27 @@ var BitmapText = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the letter spacing between each character of this Bitmap Text.
|
||||
* Can be a positive value to increase the space, or negative to reduce it.
|
||||
* Spacing is applied after the kerning values have been set.
|
||||
*
|
||||
* @method Phaser.GameObjects.BitmapText#setLetterSpacing
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} [spacing=0] - The amount of horizontal space to add between each character.
|
||||
*
|
||||
* @return {Phaser.GameObjects.BitmapText} This Game Object.
|
||||
*/
|
||||
setLetterSpacing: function (spacing)
|
||||
{
|
||||
if (spacing === undefined) { spacing = 0; }
|
||||
|
||||
this.letterSpacing = spacing;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -267,7 +299,8 @@ var BitmapText = new Class({
|
|||
var data = {
|
||||
font: this.font,
|
||||
text: this.text,
|
||||
fontSize: this.fontSize
|
||||
fontSize: this.fontSize,
|
||||
letterSpacing: this.letterSpacing
|
||||
};
|
||||
|
||||
out.data = data;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var text = src.text;
|
||||
var textLength = text.length;
|
||||
|
@ -34,6 +35,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
var chars = src.fontData.chars;
|
||||
var lineHeight = src.fontData.lineHeight;
|
||||
var letterSpacing = src.letterSpacing;
|
||||
|
||||
var xAdvance = 0;
|
||||
var yAdvance = 0;
|
||||
|
@ -94,6 +96,12 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
ctx.translate(tx, ty);
|
||||
|
||||
ctx.rotate(src.rotation);
|
||||
|
@ -140,7 +148,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
xAdvance += glyph.xAdvance;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera)
|
||||
var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var text = gameObject.text;
|
||||
var textLength = text.length;
|
||||
|
@ -30,7 +31,7 @@ var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPerce
|
|||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchBitmapText(this, camera);
|
||||
this.pipeline.batchBitmapText(this, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = BitmapTextWebGLRenderer;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -35,6 +36,14 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca
|
|||
var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX;
|
||||
var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY;
|
||||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
// Render bobs
|
||||
for (var i = 0; i < list.length; i++)
|
||||
{
|
||||
|
@ -72,6 +81,8 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca
|
|||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
module.exports = BlitterCanvasRenderer;
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera)
|
||||
var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pipeline.drawBlitter(gameObject, camera);
|
||||
this.pipeline.drawBlitter(gameObject, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = BlitterWebGLRenderer;
|
||||
|
|
|
@ -6,6 +6,40 @@
|
|||
|
||||
var Class = require('../../utils/Class');
|
||||
|
||||
/**
|
||||
* This event is dispatched when an animation starts playing.
|
||||
*
|
||||
* @event Phaser.GameObjects.Components.Animation#onStartEvent
|
||||
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
|
||||
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is dispatched when an animation repeats.
|
||||
*
|
||||
* @event Phaser.GameObjects.Components.Animation#onRepeatEvent
|
||||
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
|
||||
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
|
||||
* @param {integer} repeatCount - The number of times this animation has repeated.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is dispatched when an animation updates. This happens when the animation frame changes,
|
||||
* based on the animation frame rate and other factors like timeScale and delay.
|
||||
*
|
||||
* @event Phaser.GameObjects.Components.Animation#onUpdateEvent
|
||||
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
|
||||
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is dispatched when an animation completes playing, either naturally or via Animation.stop.
|
||||
*
|
||||
* @event Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation.
|
||||
* @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Game Object Animation Controller.
|
||||
|
@ -55,8 +89,6 @@ var Animation = new Class({
|
|||
*/
|
||||
this.isPlaying = false;
|
||||
|
||||
// Reference to the Phaser.Animation object
|
||||
|
||||
/**
|
||||
* The current Animation loaded into this Animation Controller.
|
||||
*
|
||||
|
@ -100,9 +132,9 @@ var Animation = new Class({
|
|||
this.frameRate = 0;
|
||||
|
||||
/**
|
||||
* How long the animation should play for.
|
||||
* How long the animation should play for, in milliseconds.
|
||||
* If the `frameRate` property has been set then it overrides this value,
|
||||
* otherwise frameRate is derived from `duration`.
|
||||
* otherwise the `frameRate` is derived from `duration`.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#duration
|
||||
* @type {number}
|
||||
|
@ -132,7 +164,7 @@ var Animation = new Class({
|
|||
this.skipMissedFrames = true;
|
||||
|
||||
/**
|
||||
* A delay before starting playback, in seconds.
|
||||
* A delay before starting playback, in milliseconds.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#_delay
|
||||
* @type {number}
|
||||
|
@ -154,7 +186,7 @@ var Animation = new Class({
|
|||
this._repeat = 0;
|
||||
|
||||
/**
|
||||
* Delay before the repeat starts, in seconds.
|
||||
* Delay before the repeat starts, in milliseconds.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#_repeatDelay
|
||||
* @type {number}
|
||||
|
@ -248,78 +280,91 @@ var Animation = new Class({
|
|||
this._wasPlaying = false;
|
||||
|
||||
/**
|
||||
* Container for the callback arguments.
|
||||
* Internal property tracking if this Animation is waiting to stop.
|
||||
*
|
||||
* 0 = No
|
||||
* 1 = Waiting for ms to pass
|
||||
* 2 = Waiting for repeat
|
||||
* 3 = Waiting for specific frame
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#_callbackArgs
|
||||
* @type {array}
|
||||
* @name Phaser.GameObjects.Components.Animation#_pendingStop
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this._callbackArgs = [ parent, null ];
|
||||
this._pendingStop = 0;
|
||||
|
||||
/**
|
||||
* Container for the update arguments.
|
||||
* Internal property used by _pendingStop.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#_updateParams
|
||||
* @type {array}
|
||||
* @name Phaser.GameObjects.Components.Animation#_pendingStopValue
|
||||
* @type {any}
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this._updateParams = [];
|
||||
this._pendingStopValue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the amount of time, in seconds that the animation will be delayed before starting playback.
|
||||
* Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#delay
|
||||
* @since 3.0.0
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} value - The amount of time, in seconds, to wait before starting playback.
|
||||
* @param {integer} [value=0] - The amount of time, in milliseconds, to wait before starting playback.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
delay: function (value)
|
||||
setDelay: function (value)
|
||||
{
|
||||
if (value === undefined)
|
||||
{
|
||||
return this._delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._delay = value;
|
||||
if (value === undefined) { value = 0; }
|
||||
|
||||
return this;
|
||||
}
|
||||
this._delay = value;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Gets the amount of time, in milliseconds that the animation will be delayed before starting playback.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#delay
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {integer} The amount of time, in milliseconds, the Animation will wait before starting playback.
|
||||
*/
|
||||
getDelay: function ()
|
||||
{
|
||||
return this._delay;
|
||||
},
|
||||
|
||||
/**
|
||||
* Waits for the specified delay, in milliseconds, then starts playback of the requested animation.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#delayedPlay
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} delay - [description]
|
||||
* @param {string} key - [description]
|
||||
* @param {integer} startFrame - [description]
|
||||
* @param {integer} delay - The delay, in milliseconds, to wait before starting the animation playing.
|
||||
* @param {string} key - The key of the animation to play.
|
||||
* @param {integer} [startFrame=0] - The frame of the animation to start from.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
delayedPlay: function (delay, key, startFrame)
|
||||
{
|
||||
this.play(key, true, startFrame);
|
||||
|
||||
this.nextTick += (delay * 1000);
|
||||
this.nextTick += delay;
|
||||
|
||||
return this;
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns the key of the animation currently loaded into this component.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getCurrentKey
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {string} [description]
|
||||
* @return {string} The key of the Animation loaded into this component.
|
||||
*/
|
||||
getCurrentKey: function ()
|
||||
{
|
||||
|
@ -330,15 +375,16 @@ var Animation = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Internal method used to load an animation into this component.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#load
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {integer} [startFrame=0] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
load: function (key, startFrame)
|
||||
{
|
||||
|
@ -352,18 +398,19 @@ var Animation = new Class({
|
|||
// Load the new animation in
|
||||
this.animationManager.load(this, key, startFrame);
|
||||
|
||||
return this;
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Pause the current animation and set the `isPlaying` property to `false`.
|
||||
* You can optionally pause it at a specific frame.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#pause
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Animations.Animation} [atFrame] - [description]
|
||||
* @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
pause: function (atFrame)
|
||||
{
|
||||
|
@ -379,50 +426,65 @@ var Animation = new Class({
|
|||
this.updateFrame(atFrame);
|
||||
}
|
||||
|
||||
return this;
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Resumes playback of a paused animation and sets the `isPlaying` property to `true`.
|
||||
* You can optionally tell it to start playback from a specific frame.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#paused
|
||||
* @method Phaser.GameObjects.Components.Animation#resume
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [value] - [description]
|
||||
* @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback.
|
||||
*
|
||||
* @return {(boolean|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
paused: function (value)
|
||||
resume: function (fromFrame)
|
||||
{
|
||||
if (value !== undefined)
|
||||
if (this._paused)
|
||||
{
|
||||
// Setter
|
||||
if (value)
|
||||
{
|
||||
return this.pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.resume();
|
||||
}
|
||||
this._paused = false;
|
||||
this.isPlaying = this._wasPlaying;
|
||||
}
|
||||
else
|
||||
|
||||
if (fromFrame !== undefined)
|
||||
{
|
||||
this.updateFrame(fromFrame);
|
||||
}
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* `true` if the current animation is paused, otherwise `false`.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Animation#isPaused
|
||||
* @readOnly
|
||||
* @type {boolean}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
isPaused: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this._paused;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Plays an Animation on the Game Object that owns this Animation Component.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#play
|
||||
* @fires Phaser.GameObjects.Components.Animation#onStartEvent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {boolean} [ignoreIfPlaying=false] - [description]
|
||||
* @param {integer} [startFrame=0] - [description]
|
||||
* @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager.
|
||||
* @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call.
|
||||
* @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
play: function (key, ignoreIfPlaying, startFrame)
|
||||
{
|
||||
|
@ -431,7 +493,7 @@ var Animation = new Class({
|
|||
|
||||
if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key)
|
||||
{
|
||||
return this;
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
this.load(key, startFrame);
|
||||
|
@ -453,48 +515,54 @@ var Animation = new Class({
|
|||
gameObject.visible = true;
|
||||
}
|
||||
|
||||
if (anim.onStart)
|
||||
{
|
||||
anim.onStart.apply(anim.callbackScope, this._callbackArgs.concat(anim.onStartParams));
|
||||
}
|
||||
gameObject.emit('animationstart', this.currentAnim, this.currentFrame);
|
||||
|
||||
gameObject.setSizeToFrame();
|
||||
gameObject.updateDisplayOrigin();
|
||||
|
||||
return this;
|
||||
return gameObject;
|
||||
},
|
||||
|
||||
/**
|
||||
* Value between 0 and 1. How far this animation is through, ignoring repeats and yoyos.
|
||||
* If the animation has a non-zero repeat defined, progress and totalProgress will be different
|
||||
* because progress doesn't include any repeats or repeatDelays whereas totalProgress does.
|
||||
* Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos.
|
||||
* If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different
|
||||
* because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#progress
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#getProgress
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} [value] - [description]
|
||||
*
|
||||
* @return {(number|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {float} The progress of the current animation, between 0 and 1.
|
||||
*/
|
||||
progress: function (value)
|
||||
getProgress: function ()
|
||||
{
|
||||
if (value === undefined)
|
||||
var p = this.currentFrame.progress;
|
||||
|
||||
if (!this.forward)
|
||||
{
|
||||
var p = this.currentFrame.progress;
|
||||
|
||||
if (!this.forward)
|
||||
{
|
||||
p = 1 - p;
|
||||
}
|
||||
|
||||
return p;
|
||||
p = 1 - p;
|
||||
}
|
||||
else
|
||||
|
||||
return p;
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes a value between 0 and 1 and uses it to set how far this animation is through playback.
|
||||
* Does not factor in repeats or yoyos, but does handle playing forwards or backwards.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#setProgress
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {float} [value=0] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
setProgress: function (value)
|
||||
{
|
||||
if (!this.forward)
|
||||
{
|
||||
// TODO: Set progress
|
||||
|
||||
return this;
|
||||
value = 1 - value;
|
||||
}
|
||||
|
||||
this.setCurrentFrame(this.animationManager.getFrameByProgress(value));
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -513,80 +581,90 @@ var Animation = new Class({
|
|||
{
|
||||
this.stop();
|
||||
|
||||
var sprite = this.parent;
|
||||
var frame = this.currentAnim.frames[0];
|
||||
|
||||
this.currentFrame = frame;
|
||||
|
||||
sprite.texture = frame.frame.texture;
|
||||
sprite.frame = frame.frame;
|
||||
this.setCurrentFrame(this.currentAnim.frames[0]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets or sets the number of times that the animation should repeat
|
||||
* Gets the number of times that the animation will repeat
|
||||
* after its first iteration. For example, if returns 1, the animation will
|
||||
* play a total of twice (the initial play plus 1 repeat).
|
||||
* A value of -1 means the animation will repeat indefinitely.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getRepeat
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {integer} The number of times that the animation will repeat.
|
||||
*/
|
||||
getRepeat: function ()
|
||||
{
|
||||
return this._repeat;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the number of times that the animation should repeat
|
||||
* after its first iteration. For example, if repeat is 1, the animation will
|
||||
* play a total of twice (the initial play plus 1 repeat).
|
||||
* To repeat indefinitely, use -1. repeat should always be an integer.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#repeat
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#setRepeat
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} value - [description]
|
||||
* @param {integer} value - [description]
|
||||
*
|
||||
* @return {(number|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
repeat: function (value)
|
||||
setRepeat: function (value)
|
||||
{
|
||||
if (value === undefined)
|
||||
{
|
||||
return this._repeat;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._repeat = value;
|
||||
this.repeatCounter = 0;
|
||||
this._repeat = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
this.repeatCounter = 0;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets or sets the amount of time in seconds between repeats.
|
||||
* For example, if repeat is 2 and repeatDelay is 1, the animation will play initially,
|
||||
* then wait for 1 second before it repeats, then play again, then wait 1 second again
|
||||
* Gets the amount of delay between repeats, if any.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getRepeatDelay
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {number} The delay between repeats.
|
||||
*/
|
||||
getRepeatDelay: function ()
|
||||
{
|
||||
return this._repeatDelay;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the amount of time in seconds between repeats.
|
||||
* For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially,
|
||||
* then wait for 10 seconds before repeating, then play again, then wait another 10 seconds
|
||||
* before doing its final repeat.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#repeatDelay
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#setRepeatDelay
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} [value] - [description]
|
||||
* @param {number} value - The delay to wait between repeats, in seconds.
|
||||
*
|
||||
* @return {(number|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
repeatDelay: function (value)
|
||||
setRepeatDelay: function (value)
|
||||
{
|
||||
if (value === undefined)
|
||||
{
|
||||
return this._repeatDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._repeatDelay = value;
|
||||
this._repeatDelay = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Restarts the current animation from its beginning, optionally including its delay value.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#restart
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [includeDelay=false] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
restart: function (includeDelay)
|
||||
{
|
||||
|
@ -602,115 +680,134 @@ var Animation = new Class({
|
|||
// Set frame
|
||||
this.updateFrame(this.currentAnim.frames[0]);
|
||||
|
||||
return this;
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#resume
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Animations.AnimationFrame} fromFrame - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
*/
|
||||
resume: function (fromFrame)
|
||||
{
|
||||
if (this._paused)
|
||||
{
|
||||
this._paused = false;
|
||||
this.isPlaying = this._wasPlaying;
|
||||
}
|
||||
|
||||
if (fromFrame !== undefined)
|
||||
{
|
||||
this.updateFrame(fromFrame);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Immediately stops the current animation from playing and dispatches the `animationcomplete` event.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#stop
|
||||
* @fires Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [dispatchCallbacks=false] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
stop: function (dispatchCallbacks)
|
||||
stop: function ()
|
||||
{
|
||||
if (dispatchCallbacks === undefined) { dispatchCallbacks = false; }
|
||||
this._pendingStop = 0;
|
||||
|
||||
this.isPlaying = false;
|
||||
|
||||
var anim = this.currentAnim;
|
||||
var gameObject = this.parent;
|
||||
|
||||
if (dispatchCallbacks && anim.onComplete)
|
||||
{
|
||||
anim.onComplete.apply(anim.callbackScope, this._callbackArgs.concat(anim.onCompleteParams));
|
||||
}
|
||||
gameObject.emit('animtioncomplete', this.currentAnim, this.currentFrame);
|
||||
|
||||
return this;
|
||||
return gameObject;
|
||||
},
|
||||
|
||||
/**
|
||||
* Scale the time (make it go faster / slower)
|
||||
* Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc.
|
||||
* Stops the current animation from playing after the specified time delay, given in milliseconds.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#timeScale
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#stopAfterDelay
|
||||
* @fires Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} [value] - [description]
|
||||
* @param {integer} delay - The number of miliseconds to wait before stopping this animation.
|
||||
*
|
||||
* @return {(number|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
timeScale: function (value)
|
||||
stopAfterDelay: function (delay)
|
||||
{
|
||||
if (value === undefined)
|
||||
{
|
||||
return this._timeScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._timeScale = value;
|
||||
this._pendingStop = 1;
|
||||
this._pendingStopValue = delay;
|
||||
|
||||
return this;
|
||||
}
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Stops the current animation from playing when it next repeats.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#totalFrames
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#stopOnRepeat
|
||||
* @fires Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
totalFrames: function ()
|
||||
stopOnRepeat: function ()
|
||||
{
|
||||
this._pendingStop = 2;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the current animation from playing when it next sets the given frame.
|
||||
* If this frame doesn't exist within the animation it will not stop it from playing.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#stopOnFrame
|
||||
* @fires Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.Animations.AnimationFrame} delay - The frame to check before stopping this animation.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
stopOnFrame: function (frame)
|
||||
{
|
||||
this._pendingStop = 3;
|
||||
this._pendingStopValue = frame;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default.
|
||||
* Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#setTimeScale
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} [value=1] - The time scale factor, where 1 is no change, 0.5 is half speed, etc.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
setTimeScale: function (value)
|
||||
{
|
||||
if (value === undefined) { value = 1; }
|
||||
|
||||
this._timeScale = value;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the Time Scale factor.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getTimeScale
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {number} The Time Scale value.
|
||||
*/
|
||||
getTimeScale: function ()
|
||||
{
|
||||
return this._timeScale;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the total number of frames in this animation.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getTotalFrames
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {integer} The total number of frames in this animation.
|
||||
*/
|
||||
getTotalFrames: function ()
|
||||
{
|
||||
return this.currentAnim.frames.length;
|
||||
},
|
||||
|
||||
// Value between 0 and 1. How far this animation is through, including things like delays
|
||||
// repeats, custom frame durations, etc. If the animation is set to repeat -1 it can never
|
||||
// have a duration, therefore this will return -1.
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#totalProgres
|
||||
* @since 3.0.0
|
||||
*/
|
||||
totalProgres: function ()
|
||||
{
|
||||
// TODO
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The internal update loop for the Animation Component.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#update
|
||||
* @since 3.0.0
|
||||
|
@ -720,79 +817,125 @@ var Animation = new Class({
|
|||
*/
|
||||
update: function (timestamp, delta)
|
||||
{
|
||||
if (!this.isPlaying || this.currentAnim.paused)
|
||||
if (this.currentAnim && (this.isPlaying || !this.currentAnim.paused))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.accumulator += delta * this._timeScale;
|
||||
|
||||
this.accumulator += delta * this._timeScale;
|
||||
if (this._pendingStop === 1)
|
||||
{
|
||||
this._pendingStopValue -= delta;
|
||||
|
||||
if (this.accumulator >= this.nextTick)
|
||||
{
|
||||
this.currentAnim.setFrame(this);
|
||||
if (this._pendingStopValue <= 0)
|
||||
{
|
||||
return this.currentAnim.completeAnimation(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.accumulator >= this.nextTick)
|
||||
{
|
||||
this.currentAnim.setFrame(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the given Animation Frame as being the current frame
|
||||
* and applies it to the parent Game Object, adjusting its size and origin as needed.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#setCurrentFrame
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to.
|
||||
*/
|
||||
setCurrentFrame: function (animationFrame)
|
||||
{
|
||||
var gameObject = this.parent;
|
||||
|
||||
this.currentFrame = animationFrame;
|
||||
|
||||
gameObject.texture = animationFrame.frame.texture;
|
||||
gameObject.frame = animationFrame.frame;
|
||||
|
||||
gameObject.setSizeToFrame();
|
||||
|
||||
if (animationFrame.frame.customPivot)
|
||||
{
|
||||
gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.updateDisplayOrigin();
|
||||
}
|
||||
|
||||
return gameObject;
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal frame change handler.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#updateFrame
|
||||
* @fires Phaser.GameObjects.Components.Animation#onUpdateEvent
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Animations.AnimationFrame} animationFrame - [description]
|
||||
*/
|
||||
updateFrame: function (animationFrame)
|
||||
{
|
||||
var sprite = this.parent;
|
||||
|
||||
this.currentFrame = animationFrame;
|
||||
|
||||
sprite.texture = animationFrame.frame.texture;
|
||||
sprite.frame = animationFrame.frame;
|
||||
var gameObject = this.setCurrentFrame(animationFrame);
|
||||
|
||||
if (this.isPlaying)
|
||||
{
|
||||
if (animationFrame.setAlpha)
|
||||
{
|
||||
sprite.alpha = animationFrame.alpha;
|
||||
gameObject.alpha = animationFrame.alpha;
|
||||
}
|
||||
|
||||
var anim = this.currentAnim;
|
||||
|
||||
if (anim.onUpdate)
|
||||
{
|
||||
anim.onUpdate.apply(anim.callbackScope, this._updateParams);
|
||||
}
|
||||
gameObject.emit('animationupdate', anim, animationFrame);
|
||||
|
||||
if (animationFrame.onUpdate)
|
||||
if (this._pendingStop === 3 && this._pendingStopValue === animationFrame)
|
||||
{
|
||||
animationFrame.onUpdate(sprite, animationFrame);
|
||||
this.currentAnim.completeAnimation(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets if the current Animation will yoyo when it reaches the end.
|
||||
* A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#yoyo
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.Components.Animation#setYoyo
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {boolean} [value] - [description]
|
||||
* @param {boolean} [value=false] - `true` if the animation should yoyo, `false` to not.
|
||||
*
|
||||
* @return {(boolean|Phaser.GameObjects.GameObject)} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to.
|
||||
*/
|
||||
yoyo: function (value)
|
||||
setYoyo: function (value)
|
||||
{
|
||||
if (value === undefined)
|
||||
{
|
||||
return this._yoyo;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._yoyo = value;
|
||||
if (value === undefined) { value = false; }
|
||||
|
||||
return this;
|
||||
}
|
||||
this._yoyo = value;
|
||||
|
||||
return this.parent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets if the current Animation will yoyo when it reaches the end.
|
||||
* A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Animation#getYoyo
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return {boolean} `true` if the animation is set to yoyo, `false` if not.
|
||||
*/
|
||||
getYoyo: function ()
|
||||
{
|
||||
return this._yoyo;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -803,7 +946,13 @@ var Animation = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
// TODO
|
||||
this.animationManager.off('remove', this.remove, this);
|
||||
|
||||
this.animationManager = null;
|
||||
this.parent = null;
|
||||
|
||||
this.currentAnim = null;
|
||||
this.currentFrame = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -213,7 +213,7 @@ var Transform = {
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - The x position of this Game Object.
|
||||
* @param {number} [y] - The y position of this Game Object. If not set it will use the `x` value.
|
||||
* @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value.
|
||||
* @param {number} [z=0] - The z position of this Game Object.
|
||||
* @param {number} [w=0] - The w position of this Game Object.
|
||||
*
|
||||
|
@ -368,6 +368,62 @@ var Transform = {
|
|||
this.w = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the local transform matrix for this Game Object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} tempMatrix - The matrix to populate with the values from this Game Object.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix.
|
||||
*/
|
||||
getLocalTransformMatrix: function (tempMatrix)
|
||||
{
|
||||
return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the world transform matrix for this Game Object, factoring in any parent Containers.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} tempMatrix - The matrix to populate with the values from this Game Object.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix.
|
||||
*/
|
||||
getWorldTransformMatrix: function (tempMatrix)
|
||||
{
|
||||
var parent = this.parentContainer;
|
||||
var parents = [];
|
||||
|
||||
while (parent)
|
||||
{
|
||||
parents.unshift(parent);
|
||||
parent = parent.parentContainer;
|
||||
}
|
||||
|
||||
tempMatrix.loadIdentity();
|
||||
|
||||
var length = parents.length;
|
||||
|
||||
for (var i = 0; i < length; ++i)
|
||||
{
|
||||
parent = parents[i];
|
||||
|
||||
tempMatrix.translate(parent.x, parent.y);
|
||||
tempMatrix.rotate(parent._rotation);
|
||||
tempMatrix.scale(parent._scaleX, parent._scaleY);
|
||||
}
|
||||
|
||||
tempMatrix.translate(this.x, this.y);
|
||||
tempMatrix.rotate(this._rotation);
|
||||
tempMatrix.scale(this._scaleX, this._scaleY);
|
||||
|
||||
return tempMatrix;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -15,12 +15,12 @@ var Class = require('../../utils/Class');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [a=1] - [description]
|
||||
* @param {number} [b=0] - [description]
|
||||
* @param {number} [c=0] - [description]
|
||||
* @param {number} [d=1] - [description]
|
||||
* @param {number} [tx=0] - [description]
|
||||
* @param {number} [ty=0] - [description]
|
||||
* @param {number} [a=1] - The Scale X value.
|
||||
* @param {number} [b=0] - The Shear Y value.
|
||||
* @param {number} [c=0] - The Shear X value.
|
||||
* @param {number} [d=1] - The Scale Y value.
|
||||
* @param {number} [tx=0] - The Translate X value.
|
||||
* @param {number} [ty=0] - The Translate Y value.
|
||||
*/
|
||||
var TransformMatrix = new Class({
|
||||
|
||||
|
@ -189,12 +189,12 @@ var TransformMatrix = new Class({
|
|||
* @method Phaser.GameObjects.Components.TransformMatrix#transform
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} a - [description]
|
||||
* @param {number} b - [description]
|
||||
* @param {number} c - [description]
|
||||
* @param {number} d - [description]
|
||||
* @param {number} tx - [description]
|
||||
* @param {number} ty - [description]
|
||||
* @param {number} a - The Scale X value.
|
||||
* @param {number} b - The Shear Y value.
|
||||
* @param {number} c - The Shear X value.
|
||||
* @param {number} d - The Scale Y value.
|
||||
* @param {number} tx - The Translate X value.
|
||||
* @param {number} ty - The Translate Y value.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix.
|
||||
*/
|
||||
|
@ -324,6 +324,11 @@ var TransformMatrix = new Class({
|
|||
|
||||
var matrix = this.matrix;
|
||||
|
||||
// a = scale X (1)
|
||||
// b = shear Y (0)
|
||||
// c = shear X (0)
|
||||
// d = scale Y (1)
|
||||
|
||||
var a = matrix[0];
|
||||
var b = matrix[1];
|
||||
var c = matrix[2];
|
||||
|
|
298
src/gameobjects/container/Container.js
Normal file
298
src/gameobjects/container/Container.js
Normal file
|
@ -0,0 +1,298 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Class = require('../../utils/Class');
|
||||
var Components = require('../components');
|
||||
var GameObject = require('../GameObject');
|
||||
var List = require('../../structs/List');
|
||||
var Render = require('./ContainerRender');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Container Game Object.
|
||||
*
|
||||
* @class Container
|
||||
* @extends Phaser.GameObjects.GameObject
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @extends Phaser.GameObjects.Components.BlendMode
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.Structs.List
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
||||
* @param {number} [x=0] - The horizontal position of this Game Object in the world.
|
||||
* @param {number} [y=0] - The vertical position of this Game Object in the world.
|
||||
* @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container.
|
||||
*/
|
||||
var Container = new Class({
|
||||
|
||||
Extends: GameObject,
|
||||
|
||||
Mixins: [
|
||||
Components.BlendMode,
|
||||
Components.Depth,
|
||||
Components.Transform,
|
||||
Components.Visible,
|
||||
Render,
|
||||
List
|
||||
],
|
||||
|
||||
initialize:
|
||||
|
||||
function Container (scene, x, y, children)
|
||||
{
|
||||
GameObject.call(this, scene, 'Container');
|
||||
|
||||
/**
|
||||
* The parent property as used by the List methods.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#parent
|
||||
* @type {Phaser.GameObjects.Container}
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.parent = this;
|
||||
|
||||
/**
|
||||
* An array holding the children of this Container.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#list
|
||||
* @type {Phaser.GameObjects.GameObject[]}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.list = [];
|
||||
|
||||
/**
|
||||
* The cursor position.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#position
|
||||
* @type {integer}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.position = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#localTransform
|
||||
* @type {Phaser.GameObjects.Components.TransformMatrix}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.localTransform = new Components.TransformMatrix();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#tempTransformMatrix
|
||||
* @type {Phaser.GameObjects.Components.TransformMatrix}
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.tempTransformMatrix = new Components.TransformMatrix();
|
||||
|
||||
/**
|
||||
* A callback that is invoked every time a child is added to this list.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#addCallback
|
||||
* @type {function}
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.addCallback = this.addHandler;
|
||||
|
||||
/**
|
||||
* A callback that is invoked every time a child is removed from this list.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#removeCallback
|
||||
* @type {function}
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.removeCallback = this.removeHandler;
|
||||
|
||||
/**
|
||||
* A reference to the Scene Display List.
|
||||
*
|
||||
* @name Phaser.GameObjects.Container#_displayList
|
||||
* @type {Phaser.GameObjects.DisplayList}
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this._displayList = scene.sys.displayList;
|
||||
|
||||
this.setPosition(x, y);
|
||||
|
||||
if (Array.isArray(children))
|
||||
{
|
||||
this.addMultiple(children);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal add handler.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#addHandler
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Container} list - The List the Game Object was added to (also this Container)
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container.
|
||||
*/
|
||||
addHandler: function (list, gameObject)
|
||||
{
|
||||
this._displayList.remove(gameObject);
|
||||
|
||||
gameObject.on('destroy', this.remove, this);
|
||||
|
||||
if (gameObject.parentContainer)
|
||||
{
|
||||
gameObject.parentContainer.remove(gameObject);
|
||||
}
|
||||
|
||||
gameObject.parentContainer = list;
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal remove handler.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#removeHandler
|
||||
* @private
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Container} list - The List the Game Object was removed from (also this Container)
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container.
|
||||
*/
|
||||
removeHandler: function (list, gameObject)
|
||||
{
|
||||
gameObject.off('destroy', list.remove, this);
|
||||
|
||||
gameObject.parentContainer = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties,
|
||||
* and transforms it into the space of this Container, then returns it in the output object.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#pointToContainer
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed.
|
||||
* @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned.
|
||||
*
|
||||
* @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point.
|
||||
*/
|
||||
pointToContainer: function (source, output)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
|
||||
if (this.parentContainer)
|
||||
{
|
||||
return this.parentContainer.pointToContainer(source, output);
|
||||
}
|
||||
|
||||
var tempMatrix = this.tempTransformMatrix;
|
||||
|
||||
// No need to loadIdentity because applyITRS overwrites every value anyway
|
||||
tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY);
|
||||
|
||||
tempMatrix.invert();
|
||||
|
||||
tempMatrix.transformPoint(source.x, source.y, output);
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#localToWorld
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - The child of this Container.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} [camera] - The camera to transform against.
|
||||
* @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned.
|
||||
*
|
||||
* @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point.
|
||||
*/
|
||||
localToWorld: function (child, camera, output)
|
||||
{
|
||||
if (camera === undefined) { camera = this.scene.sys.cameras.main; }
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
|
||||
if (this.exists(child))
|
||||
{
|
||||
// Do matrix magic here
|
||||
// See: Camera.getWorldPoint and InputManager.hitTest
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Container removing it and all children from the Display List and
|
||||
* severing all ties to parent resources.
|
||||
*
|
||||
* Use this to remove a Container from your game if you don't ever plan to use it again.
|
||||
* As long as no reference to it exists within your own code it should become free for
|
||||
* garbage collection by the browser.
|
||||
*
|
||||
* If you just want to temporarily disable an object then look at using the
|
||||
* Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#destroy
|
||||
* @since 3.4.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
// This Game Object had already been destroyed
|
||||
if (!this.scene)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.preDestroy)
|
||||
{
|
||||
this.preDestroy.call(this);
|
||||
}
|
||||
|
||||
this.emit('destroy', this);
|
||||
|
||||
var sys = this.scene.sys;
|
||||
|
||||
sys.displayList.remove(this);
|
||||
|
||||
if (this.data)
|
||||
{
|
||||
this.data.destroy();
|
||||
|
||||
this.data = undefined;
|
||||
}
|
||||
|
||||
// Tell the Scene to re-sort the children
|
||||
sys.queueDepthSort();
|
||||
|
||||
this.active = false;
|
||||
this.visible = false;
|
||||
|
||||
this.scene = undefined;
|
||||
|
||||
this.removeAllListeners();
|
||||
|
||||
this.removeAll();
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.parent = null;
|
||||
this.parentContainer = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Container;
|
54
src/gameobjects/container/ContainerCanvasRenderer.js
Normal file
54
src/gameobjects/container/ContainerCanvasRenderer.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the Canvas Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#renderCanvas
|
||||
* @since 3.4.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
|
||||
* @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var children = container.list;
|
||||
var transformMatrix = container.localTransform;
|
||||
|
||||
if (parentMatrix === undefined)
|
||||
{
|
||||
transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformMatrix.loadIdentity();
|
||||
transformMatrix.multiply(parentMatrix);
|
||||
transformMatrix.translate(container.x, container.y);
|
||||
transformMatrix.rotate(container.rotation);
|
||||
transformMatrix.scale(container.scaleX, container.scaleY);
|
||||
}
|
||||
|
||||
for (var index = 0; index < children.length; ++index)
|
||||
{
|
||||
children[index].renderCanvas(renderer, children[index], interpolationPercentage, camera, transformMatrix);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ContainerCanvasRenderer;
|
35
src/gameobjects/container/ContainerCreator.js
Normal file
35
src/gameobjects/container/ContainerCreator.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
var Container = require('./Container');
|
||||
var GameObjectCreator = require('../GameObjectCreator');
|
||||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
|
||||
/**
|
||||
* Creates a new Container Game Object and returns it.
|
||||
*
|
||||
* Note: This method will only be available if the Container Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#container
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.Container} The Game Object that was created.
|
||||
*/
|
||||
GameObjectCreator.register('container', function (config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
var y = GetAdvancedValue(config, 'y', 0);
|
||||
|
||||
var container = new Container(this.scene, x, y);
|
||||
|
||||
BuildGameObject(this.scene, container, config);
|
||||
|
||||
return container;
|
||||
});
|
28
src/gameobjects/container/ContainerFactory.js
Normal file
28
src/gameobjects/container/ContainerFactory.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Container = require('./Container');
|
||||
var GameObjectFactory = require('../GameObjectFactory');
|
||||
|
||||
/**
|
||||
* Creates a new Container Game Object and adds it to the Scene.
|
||||
*
|
||||
* Note: This method will only be available if the Container Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#container
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Container} The Game Object that was created.
|
||||
*/
|
||||
GameObjectFactory.register('container', function (x, y, children)
|
||||
{
|
||||
return this.displayList.add(new Container(this.scene, x, y, children));
|
||||
});
|
26
src/gameobjects/container/ContainerRender.js
Normal file
26
src/gameobjects/container/ContainerRender.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var renderWebGL = require('../../utils/NOOP');
|
||||
var renderCanvas = require('../../utils/NOOP');
|
||||
|
||||
if (WEBGL_RENDERER)
|
||||
{
|
||||
renderWebGL = require('./ContainerWebGLRenderer');
|
||||
}
|
||||
|
||||
if (CANVAS_RENDERER)
|
||||
{
|
||||
renderCanvas = require('./ContainerCanvasRenderer');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
renderWebGL: renderWebGL,
|
||||
renderCanvas: renderCanvas
|
||||
|
||||
};
|
54
src/gameobjects/container/ContainerWebGLRenderer.js
Normal file
54
src/gameobjects/container/ContainerWebGLRenderer.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the WebGL Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.Container#renderWebGL
|
||||
* @since 3.4.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer.
|
||||
* @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var children = container.list;
|
||||
var transformMatrix = container.localTransform;
|
||||
|
||||
if (parentMatrix === undefined)
|
||||
{
|
||||
transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformMatrix.loadIdentity();
|
||||
transformMatrix.multiply(parentMatrix);
|
||||
transformMatrix.translate(container.x, container.y);
|
||||
transformMatrix.rotate(container.rotation);
|
||||
transformMatrix.scale(container.scaleX, container.scaleY);
|
||||
}
|
||||
|
||||
for (var index = 0; index < children.length; ++index)
|
||||
{
|
||||
children[index].renderWebGL(renderer, children[index], interpolationPercentage, camera, transformMatrix);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ContainerWebGLRenderer;
|
|
@ -912,6 +912,43 @@ var Graphics = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a pie-chart slice shape centered at `x`, `y` with the given radius.
|
||||
* You must define the start and end angle of the slice.
|
||||
*
|
||||
* Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman.
|
||||
* Setting it to `false` creates a shape like a slice of pie.
|
||||
*
|
||||
* This method will begin a new path and close the path at the end of it.
|
||||
* To display the actual slice you need to call either `strokePath` or `fillPath` after it.
|
||||
*
|
||||
* @method Phaser.GameObjects.Graphics#slice
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} x - The horizontal center of the slice.
|
||||
* @param {number} y - The vertical center of the slice.
|
||||
* @param {number} radius - The radius of the slice.
|
||||
* @param {number} startAngle - The start angle of the slice, given in radians.
|
||||
* @param {number} endAngle - The end angle of the slice, given in radians.
|
||||
* @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise?
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} This Game Object.
|
||||
*/
|
||||
slice: function (x, y, radius, startAngle, endAngle, anticlockwise)
|
||||
{
|
||||
if (anticlockwise === undefined) { anticlockwise = false; }
|
||||
|
||||
this.commandBuffer.push(Commands.BEGIN_PATH);
|
||||
|
||||
this.commandBuffer.push(Commands.MOVE_TO, x, y);
|
||||
|
||||
this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise);
|
||||
|
||||
this.commandBuffer.push(Commands.CLOSE_PATH);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -1096,7 +1133,7 @@ var Graphics = new Class({
|
|||
|
||||
if (ctx)
|
||||
{
|
||||
this.renderCanvas(sys.game.renderer, this, 0, Graphics.TargetCamera, ctx);
|
||||
this.renderCanvas(sys.game.renderer, this, 0.0, Graphics.TargetCamera, null, ctx);
|
||||
|
||||
if (sys.game.renderer.gl && texture)
|
||||
{
|
||||
|
|
|
@ -20,10 +20,11 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
* @param {CanvasRenderingContext2D} renderTargetCtx - [description]
|
||||
* @param {boolean} allowClip - [description]
|
||||
*/
|
||||
var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, renderTargetCtx, allowClip)
|
||||
var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -69,6 +70,11 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c
|
|||
}
|
||||
|
||||
ctx.save();
|
||||
if (parentMatrix)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY);
|
||||
ctx.rotate(srcRotation);
|
||||
ctx.scale(srcScaleX, srcScaleY);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var GameObjectCreator = require('../GameObjectCreator');
|
||||
var Graphics = require('./Graphics');
|
||||
|
||||
|
@ -15,13 +16,21 @@ var Graphics = require('./Graphics');
|
|||
* @method Phaser.GameObjects.GameObjectCreator#graphics
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
* @param {object} [config] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} The Game Object that was created.
|
||||
*/
|
||||
GameObjectCreator.register('graphics', function (config)
|
||||
{
|
||||
return new Graphics(this.scene, config);
|
||||
var add = GetAdvancedValue(config, 'add', true);
|
||||
var graphics = new Graphics(this.scene, config);
|
||||
|
||||
if (add)
|
||||
{
|
||||
this.scene.sys.displayList.add(graphics);
|
||||
}
|
||||
|
||||
return graphics;
|
||||
});
|
||||
|
||||
// When registering a factory function 'this' refers to the GameObjectCreator context.
|
||||
|
|
|
@ -15,7 +15,7 @@ var GameObjectFactory = require('../GameObjectFactory');
|
|||
* @method Phaser.GameObjects.GameObjectFactory#graphics
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
* @param {object} [config] - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} The Game Object that was created.
|
||||
*/
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera)
|
||||
var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchGraphics(this, camera);
|
||||
this.pipeline.batchGraphics(this, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = GraphicsWebGLRenderer;
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
renderer.drawImage(src, camera);
|
||||
renderer.drawImage(src, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = ImageCanvasRenderer;
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchSprite(src, camera);
|
||||
this.pipeline.batchSprite(src, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = ImageWebGLRenderer;
|
||||
|
|
|
@ -22,6 +22,7 @@ var GameObjects = {
|
|||
GameObject: require('./GameObject'),
|
||||
BitmapText: require('./bitmaptext/static/BitmapText'),
|
||||
Blitter: require('./blitter/Blitter'),
|
||||
Container: require('./container/Container'),
|
||||
DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapText'),
|
||||
Graphics: require('./graphics/Graphics.js'),
|
||||
Group: require('./group/Group'),
|
||||
|
@ -39,6 +40,7 @@ var GameObjects = {
|
|||
|
||||
Factories: {
|
||||
Blitter: require('./blitter/BlitterFactory'),
|
||||
Container: require('./container/ContainerFactory'),
|
||||
DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapTextFactory'),
|
||||
Graphics: require('./graphics/GraphicsFactory'),
|
||||
Group: require('./group/GroupFactory'),
|
||||
|
@ -56,6 +58,7 @@ var GameObjects = {
|
|||
|
||||
Creators: {
|
||||
Blitter: require('./blitter/BlitterCreator'),
|
||||
Container: require('./container/ContainerCreator'),
|
||||
DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapTextCreator'),
|
||||
Graphics: require('./graphics/GraphicsCreator'),
|
||||
Group: require('./group/GroupCreator'),
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchMesh(src, camera);
|
||||
this.pipeline.batchMesh(src, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = MeshWebGLRenderer;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera)
|
||||
var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var emitters = emitterManager.emitters.list;
|
||||
|
||||
|
@ -29,6 +30,15 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol
|
|||
return;
|
||||
}
|
||||
|
||||
var ctx = renderer.currentContext;
|
||||
|
||||
ctx.save();
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < emitters.length; i++)
|
||||
{
|
||||
var emitter = emitters[i];
|
||||
|
@ -41,7 +51,6 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol
|
|||
continue;
|
||||
}
|
||||
|
||||
var ctx = renderer.currentContext;
|
||||
|
||||
var lastAlpha = ctx.globalAlpha;
|
||||
var cameraScrollX = camera.scrollX * emitter.scrollFactorX;
|
||||
|
@ -102,6 +111,8 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol
|
|||
|
||||
ctx.globalAlpha = lastAlpha;
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
};
|
||||
|
||||
module.exports = ParticleManagerCanvasRenderer;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera)
|
||||
var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
var emitters = emitterManager.emitters;
|
||||
|
||||
|
@ -29,7 +30,7 @@ var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpola
|
|||
return;
|
||||
}
|
||||
|
||||
this.pipeline.drawEmitterManager(emitterManager, camera);
|
||||
this.pipeline.drawEmitterManager(emitterManager, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = ParticleManagerWebGLRenderer;
|
||||
|
|
|
@ -141,7 +141,7 @@ var RenderTexture = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
GameObject.destroy.call(this);
|
||||
GameObject.prototype.destroy.call(this);
|
||||
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -73,6 +74,11 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati
|
|||
}
|
||||
|
||||
ctx.save();
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY);
|
||||
ctx.rotate(renderTexture.rotation);
|
||||
ctx.scale(renderTexture.scaleX, renderTexture.scaleY);
|
||||
|
|
|
@ -20,8 +20,9 @@ var Utils = require('../../renderer/webgl/Utils');
|
|||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -42,7 +43,8 @@ var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolatio
|
|||
0, 0, renderTexture.texture.width, renderTexture.texture.height,
|
||||
Utils.getTintAppendFloatAlpha(renderTexture.tintTopLeft, renderTexture.alphaTopLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintTopRight, renderTexture.alphaTopRight), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomLeft, renderTexture.alphaBottomLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomRight, renderTexture.alphaBottomRight),
|
||||
0, 0,
|
||||
camera
|
||||
camera,
|
||||
parentMatrix
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
renderer.drawImage(src, camera);
|
||||
renderer.drawImage(src, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = SpriteCanvasRenderer;
|
||||
|
|
|
@ -19,15 +19,16 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.pipeline.batchSprite(src, camera);
|
||||
this.pipeline.batchSprite(src, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = SpriteWebGLRenderer;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '')
|
||||
{
|
||||
|
@ -55,6 +56,12 @@ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camer
|
|||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
var tx = src.x - camera.scrollX * src.scrollFactorX;
|
||||
var ty = src.y - camera.scrollY * src.scrollFactorY;
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../../GameObject');
|
|||
* @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '')
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera
|
|||
src.dirty = false;
|
||||
}
|
||||
|
||||
this.pipeline.batchText(this, camera);
|
||||
this.pipeline.batchText(this, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = TextWebGLRenderer;
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -88,6 +89,12 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix !== undefined)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
ctx.translate(dx, dy);
|
||||
|
||||
ctx.translate(tx, ty);
|
||||
|
|
|
@ -19,8 +19,9 @@ var GameObject = require('../GameObject');
|
|||
* @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
|
||||
*/
|
||||
var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
||||
var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))
|
||||
{
|
||||
|
@ -29,7 +30,7 @@ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
src.updateTileTexture();
|
||||
|
||||
this.pipeline.batchTileSprite(this, camera);
|
||||
this.pipeline.batchTileSprite(this, camera, parentMatrix);
|
||||
};
|
||||
|
||||
module.exports = TileSpriteWebGLRenderer;
|
||||
|
|
|
@ -171,7 +171,7 @@ var Line = new Class({
|
|||
{
|
||||
if (vec2 === undefined) { vec2 = new Vector2(); }
|
||||
|
||||
vec2.setTo(this.x1, this.y1);
|
||||
vec2.set(this.x1, this.y1);
|
||||
|
||||
return vec2;
|
||||
},
|
||||
|
@ -192,7 +192,7 @@ var Line = new Class({
|
|||
{
|
||||
if (vec2 === undefined) { vec2 = new Vector2(); }
|
||||
|
||||
vec2.setTo(this.x2, this.y2);
|
||||
vec2.set(this.x2, this.y2);
|
||||
|
||||
return vec2;
|
||||
},
|
||||
|
|
|
@ -764,6 +764,7 @@ var InputPlugin = new Class({
|
|||
}
|
||||
|
||||
pointer.dragState = 0;
|
||||
list.splice(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -270,7 +270,7 @@ var Pointer = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {(Phaser.Math.Vector2|object)} output - [description]
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - [description]
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} [description]
|
||||
*/
|
||||
|
|
|
@ -190,13 +190,24 @@ var KeyboardManager = new Class({
|
|||
this.target.removeEventListener('keyup', this.handler);
|
||||
},
|
||||
|
||||
/**
|
||||
* @typedef {object} CursorKeys
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard.Key} [up] - [description]
|
||||
* @property {Phaser.Input.Keyboard.Key} [down] - [description]
|
||||
* @property {Phaser.Input.Keyboard.Key} [left] - [description]
|
||||
* @property {Phaser.Input.Keyboard.Key} [right] - [description]
|
||||
* @property {Phaser.Input.Keyboard.Key} [space] - [description]
|
||||
* @property {Phaser.Input.Keyboard.Key} [shift] - [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift.
|
||||
*
|
||||
* @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {CursorKeys} [description]
|
||||
*/
|
||||
createCursorKeys: function ()
|
||||
{
|
||||
|
@ -215,9 +226,9 @@ var KeyboardManager = new Class({
|
|||
*
|
||||
* For example,
|
||||
*
|
||||
* addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } );
|
||||
* addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S });
|
||||
*
|
||||
* would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object.
|
||||
* would return an object containing properties (`up` and `down`) referring to {@link Phaser.Input.Keyboard.Key} objects.
|
||||
*
|
||||
* @method Phaser.Input.Keyboard.KeyboardManager#addKeys
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
*/
|
||||
var JustDown = function (key)
|
||||
{
|
||||
var current = false;
|
||||
|
||||
if (key.isDown)
|
||||
if (key._justDown)
|
||||
{
|
||||
current = key._justDown;
|
||||
key._justDown = false;
|
||||
}
|
||||
|
||||
return current;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = JustDown;
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
*/
|
||||
var JustUp = function (key)
|
||||
{
|
||||
var current = false;
|
||||
|
||||
if (key.isDown)
|
||||
if (key._justUp)
|
||||
{
|
||||
current = key._justUp;
|
||||
key._justUp = false;
|
||||
}
|
||||
|
||||
return current;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = JustUp;
|
||||
|
|
|
@ -40,13 +40,12 @@ var ProcessKeyDown = function (key, event)
|
|||
key.isUp = false;
|
||||
key.timeDown = event.timeStamp;
|
||||
key.duration = 0;
|
||||
key._justDown = true;
|
||||
key._justUp = false;
|
||||
}
|
||||
|
||||
key.repeats++;
|
||||
|
||||
key._justDown = true;
|
||||
key._justUp = false;
|
||||
|
||||
return key;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Resets a Key object back to its default settings.
|
||||
* Optionally resets the keyCode as well.
|
||||
* Resets a Key object back to its default settings.
|
||||
* Optionally resets the keyCode as well.
|
||||
*
|
||||
* @function Phaser.Input.Keyboard.Keys.ResetKey
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Calculates a linear (interpolation) value over t.
|
||||
*
|
||||
* @function Phaser.Math.Linear
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} p0 - [description]
|
||||
* @param {number} p1 - [description]
|
||||
* @param {float} t - [description]
|
||||
* @param {number} p0 - The first point
|
||||
* @param {number} p1 - The second point
|
||||
* @param {float} t -The percentage between p0 and p1 to return represented as a number between 0 and 1.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The step t% of the way between p0 and p1
|
||||
*/
|
||||
var Linear = function (p0, p1, t)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,22 @@ var Vector2 = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is an alias for `Vector2.set`.
|
||||
*
|
||||
* @method Phaser.Math.Vector2#setTo
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} [y=x] - [description]
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} This Vector2.
|
||||
*/
|
||||
setTo: function (x, y)
|
||||
{
|
||||
return this.set(x, y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the `x` and `y` values of this object from a given polar coordinate.
|
||||
*
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
var Linear = require('../Linear');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Linear Interpolation Method.
|
||||
*
|
||||
* @function Phaser.Math.Interpolation.Linear
|
||||
* @since 3.0.0
|
||||
* @see https://en.wikipedia.org/wiki/Linear_interpolation
|
||||
*
|
||||
* @param {float} v - [description]
|
||||
* @param {number} k - [description]
|
||||
* @param {number[]} v - The input array of values to interpolate between.
|
||||
* @param {!number} k - The percentage of interploation, between 0 and 1.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {!number} The interpolated value.
|
||||
*/
|
||||
var LinearInterpolation = function (v, k)
|
||||
{
|
||||
|
|
|
@ -426,6 +426,32 @@ var StaticBody = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticBody#setOffset
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.StaticBody} This Static Body object.
|
||||
*/
|
||||
setOffset: function (x, y)
|
||||
{
|
||||
if (y === undefined) { y = x; }
|
||||
|
||||
this.world.staticTree.remove(this);
|
||||
|
||||
this.offset.set(x, y);
|
||||
|
||||
this.updateCenter();
|
||||
|
||||
this.world.staticTree.insert(this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
// Phaser.Physics.Matter.World
|
||||
|
||||
var Bodies = require('./lib/factory/Bodies');
|
||||
var Class = require('../../utils/Class');
|
||||
var Common = require('./lib/core/Common');
|
||||
var Composite = require('./lib/body/Composite');
|
||||
var Engine = require('./lib/core/Engine');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
@ -15,8 +14,9 @@ var GetFastValue = require('../../utils/object/GetFastValue');
|
|||
var GetValue = require('../../utils/object/GetValue');
|
||||
var MatterBody = require('./lib/body/Body');
|
||||
var MatterEvents = require('./lib/core/Events');
|
||||
var MatterWorld = require('./lib/body/World');
|
||||
var MatterTileBody = require('./MatterTileBody');
|
||||
var MatterWorld = require('./lib/body/World');
|
||||
var Vector = require('./lib/geometry/Vector');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
|
@ -206,7 +206,9 @@ var World = new Class({
|
|||
debugShowVelocity: GetValue(config, 'debugShowVelocity', true),
|
||||
bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff),
|
||||
staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff),
|
||||
velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00)
|
||||
velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00),
|
||||
debugShowJoint: GetValue(config, 'debugShowJoint', true),
|
||||
jointDebugColor: GetValue(config, 'debugJointColor', 0x000000)
|
||||
};
|
||||
|
||||
if (this.drawDebug)
|
||||
|
@ -391,7 +393,7 @@ var World = new Class({
|
|||
{
|
||||
var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 });
|
||||
|
||||
graphic.setZ(Number.MAX_VALUE);
|
||||
graphic.setDepth(Number.MAX_VALUE);
|
||||
|
||||
this.debugGraphic = graphic;
|
||||
|
||||
|
@ -730,7 +732,9 @@ var World = new Class({
|
|||
graphics.lineStyle(1, this.defaults.bodyDebugColor);
|
||||
graphics.beginPath();
|
||||
|
||||
for (var i = 0; i < bodies.length; i++)
|
||||
var i,j;
|
||||
|
||||
for (i = 0; i < bodies.length; i++)
|
||||
{
|
||||
if (!bodies[i].render.visible)
|
||||
{
|
||||
|
@ -739,7 +743,7 @@ var World = new Class({
|
|||
|
||||
// Handle drawing both single bodies and compound bodies. If compound, draw both the
|
||||
// convex hull (first part) and the rest of the bodies.
|
||||
for (var j = 0; j < bodies[i].parts.length; j++)
|
||||
for (j = 0; j < bodies[i].parts.length; j++)
|
||||
{
|
||||
var body = bodies[i].parts[j];
|
||||
|
||||
|
@ -759,6 +763,99 @@ var World = new Class({
|
|||
}
|
||||
|
||||
graphics.closePath();
|
||||
|
||||
if (this.defaults.debugShowJoint)
|
||||
{
|
||||
graphics.lineStyle(2, this.defaults.jointDebugColor);
|
||||
|
||||
// Render constraints
|
||||
var constraints = Composite.allConstraints(this.localWorld);
|
||||
|
||||
for (i = 0; i < constraints.length; i++)
|
||||
{
|
||||
var constraint = constraints[i];
|
||||
|
||||
if (!constraint.render.visible || !constraint.pointA || !constraint.pointB)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (constraint.render.lineWidth)
|
||||
{
|
||||
graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle));
|
||||
}
|
||||
|
||||
var bodyA = constraint.bodyA;
|
||||
var bodyB = constraint.bodyB;
|
||||
var start;
|
||||
var end;
|
||||
|
||||
if (bodyA)
|
||||
{
|
||||
start = Vector.add(bodyA.position, constraint.pointA);
|
||||
}
|
||||
else
|
||||
{
|
||||
start = constraint.pointA;
|
||||
}
|
||||
|
||||
if (constraint.render.type === 'pin')
|
||||
{
|
||||
graphics.beginPath();
|
||||
graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI);
|
||||
graphics.closePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bodyB)
|
||||
{
|
||||
end = Vector.add(bodyB.position, constraint.pointB);
|
||||
}
|
||||
else
|
||||
{
|
||||
end = constraint.pointB;
|
||||
}
|
||||
|
||||
graphics.beginPath();
|
||||
graphics.moveTo(start.x, start.y);
|
||||
|
||||
if (constraint.render.type === 'spring')
|
||||
{
|
||||
var delta = Vector.sub(end, start);
|
||||
var normal = Vector.perp(Vector.normalise(delta));
|
||||
var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20));
|
||||
var offset;
|
||||
|
||||
for (j = 1; j < coils; j += 1)
|
||||
{
|
||||
offset = (j % 2 === 0) ? 1 : -1;
|
||||
|
||||
graphics.lineTo(
|
||||
start.x + delta.x * (j / coils) + normal.x * offset * 4,
|
||||
start.y + delta.y * (j / coils) + normal.y * offset * 4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
graphics.lineTo(end.x, end.y);
|
||||
}
|
||||
|
||||
if (constraint.render.lineWidth)
|
||||
{
|
||||
graphics.strokePath();
|
||||
}
|
||||
|
||||
if (constraint.render.anchors)
|
||||
{
|
||||
graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle));
|
||||
graphics.beginPath();
|
||||
graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI);
|
||||
graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI);
|
||||
graphics.closePath();
|
||||
graphics.fillPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
@ -440,22 +441,20 @@ var CanvasRenderer = new Class({
|
|||
}
|
||||
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
|
||||
if (camera._fadeAlpha > 0 || camera._flashAlpha > 0)
|
||||
if (camera._fadeAlpha > 0)
|
||||
{
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
|
||||
// fade rendering
|
||||
ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')';
|
||||
ctx.globalAlpha = camera._fadeAlpha;
|
||||
ctx.fillStyle = 'rgba(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ',' + camera._fadeAlpha + ')';
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
}
|
||||
|
||||
if (camera._flashAlpha > 0)
|
||||
{
|
||||
// flash rendering
|
||||
ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')';
|
||||
ctx.globalAlpha = camera._flashAlpha;
|
||||
ctx.fillStyle = 'rgba(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ',' + camera._flashAlpha + ')';
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
|
||||
ctx.globalAlpha = 1.0;
|
||||
}
|
||||
|
||||
// Reset the camera scissor
|
||||
|
|
|
@ -14,8 +14,9 @@ var roundPixels = false;
|
|||
*
|
||||
* @param {Phaser.GameObjects.GameObject} src - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - [description]
|
||||
*/
|
||||
var DrawImage = function (src, camera)
|
||||
var DrawImage = function (src, camera, parentMatrix)
|
||||
{
|
||||
var ctx = this.currentContext;
|
||||
var frame = src.frame;
|
||||
|
@ -87,6 +88,13 @@ var DrawImage = function (src, camera)
|
|||
|
||||
ctx.save();
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var matrix = parentMatrix.matrix;
|
||||
|
||||
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
||||
}
|
||||
|
||||
ctx.translate(tx, ty);
|
||||
|
||||
ctx.rotate(src.rotation);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
@ -698,10 +699,18 @@ var FlatTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Graphics} graphics - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchGraphics: function (graphics, camera)
|
||||
batchGraphics: function (graphics, camera, parentTransformMatrix)
|
||||
{
|
||||
if (graphics.commandBuffer.length <= 0) { return; }
|
||||
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
|
@ -750,12 +759,38 @@ var FlatTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
var pathArrayIndex;
|
||||
var pathArrayLength;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @author Felipe Alfonso <@bitnenfer>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
@ -365,9 +366,17 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
drawEmitterManager: function (emitterManager, camera)
|
||||
drawEmitterManager: function (emitterManager, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
var roundPixels = this.renderer.config.roundPixels;
|
||||
|
@ -391,6 +400,31 @@ var TextureTintPipeline = new Class({
|
|||
var vertexComponentCount = this.vertexComponentCount;
|
||||
var vertexCapacity = this.vertexCapacity;
|
||||
var texture = emitterManager.defaultFrame.source.glTexture;
|
||||
var pca, pcb, pcc, pcd, pce, pcf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
|
||||
pca = cma * pma + cmb * pmc;
|
||||
pcb = cma * pmb + cmb * pmd;
|
||||
pcc = cmc * pma + cmd * pmc;
|
||||
pcd = cmc * pmb + cmd * pmd;
|
||||
pce = cme * pma + cmf * pmc + pme;
|
||||
pcf = cme * pmb + cmf * pmd + pmf;
|
||||
|
||||
cma = pca;
|
||||
cmb = pcb;
|
||||
cmc = pcc;
|
||||
cmd = pcd;
|
||||
cme = pce;
|
||||
cmf = pcf;
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
||||
|
@ -529,9 +563,17 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Blitter} blitter - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
drawBlitter: function (blitter, camera)
|
||||
drawBlitter: function (blitter, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
var roundPixels = this.renderer.config.roundPixels;
|
||||
|
@ -554,6 +596,29 @@ var TextureTintPipeline = new Class({
|
|||
var blitterX = blitter.x - cameraScrollX;
|
||||
var blitterY = blitter.y - cameraScrollY;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = a * pma + b * pmc;
|
||||
var pcb = a * pmb + b * pmd;
|
||||
var pcc = c * pma + d * pmc;
|
||||
var pcd = c * pmb + d * pmd;
|
||||
var pce = e * pma + f * pmc + pme;
|
||||
var pcf = e * pmb + f * pmd + pmf;
|
||||
|
||||
a = pca;
|
||||
b = pcb;
|
||||
c = pcc;
|
||||
d = pcd;
|
||||
e = pce;
|
||||
f = pcf;
|
||||
}
|
||||
|
||||
for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex)
|
||||
{
|
||||
var batchSize = Math.min(length, this.maxQuads);
|
||||
|
@ -650,16 +715,24 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Sprite} sprite - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchSprite: function (sprite, camera)
|
||||
batchSprite: function (sprite, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
if (this.vertexCount + 6 > this.vertexCapacity)
|
||||
{
|
||||
this.flush();
|
||||
}
|
||||
|
||||
|
||||
var roundPixels = this.renderer.config.roundPixels;
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
var vertexViewF32 = this.vertexViewF32;
|
||||
|
@ -704,12 +777,39 @@ var TextureTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
var tx0 = x * mva + y * mvc + mve;
|
||||
var ty0 = x * mvb + y * mvd + mvf;
|
||||
var tx1 = x * mva + yh * mvc + mve;
|
||||
|
@ -782,9 +882,17 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Mesh} mesh - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchMesh: function (mesh, camera)
|
||||
batchMesh: function (mesh, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
var vertices = mesh.vertices;
|
||||
var length = vertices.length;
|
||||
var vertexCount = (length / 2)|0;
|
||||
|
@ -825,13 +933,39 @@ var TextureTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var vertexOffset = 0;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
||||
|
@ -871,9 +1005,17 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.BitmapText} bitmapText - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchBitmapText: function (bitmapText, camera)
|
||||
batchBitmapText: function (bitmapText, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
if (this.vertexCount + 6 > this.vertexCapacity)
|
||||
|
@ -946,6 +1088,7 @@ var TextureTintPipeline = new Class({
|
|||
var rotation = -bitmapText.rotation;
|
||||
var scaleX = bitmapText.scaleX;
|
||||
var scaleY = bitmapText.scaleY;
|
||||
var letterSpacing = bitmapText.letterSpacing;
|
||||
var sr = Math.sin(rotation);
|
||||
var cr = Math.cos(rotation);
|
||||
var sra = cr * scaleX;
|
||||
|
@ -960,13 +1103,39 @@ var TextureTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var vertexOffset = 0;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
||||
|
@ -1005,7 +1174,7 @@ var TextureTintPipeline = new Class({
|
|||
x += (kerningOffset !== undefined) ? kerningOffset : 0;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
@ -1105,9 +1274,17 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchDynamicBitmapText: function (bitmapText, camera)
|
||||
batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
if (this.vertexCount + 6 > this.vertexCapacity)
|
||||
|
@ -1178,6 +1355,7 @@ var TextureTintPipeline = new Class({
|
|||
var rotation = -bitmapText.rotation;
|
||||
var scaleX = bitmapText.scaleX;
|
||||
var scaleY = bitmapText.scaleY;
|
||||
var letterSpacing = bitmapText.letterSpacing;
|
||||
var sr = Math.sin(rotation);
|
||||
var cr = Math.cos(rotation);
|
||||
var sra = cr * scaleX;
|
||||
|
@ -1192,15 +1370,41 @@ var TextureTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var crop = (bitmapText.cropWidth > 0 || bitmapText.cropHeight > 0);
|
||||
var uta, utb, utc, utd, ute, utf;
|
||||
var vertexOffset = 0;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
||||
|
@ -1252,7 +1456,7 @@ var TextureTintPipeline = new Class({
|
|||
x += (kerningOffset !== undefined) ? kerningOffset : 0;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
@ -1414,8 +1618,9 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.Text} text - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchText: function (text, camera)
|
||||
batchText: function (text, camera, parentTransformMatrix)
|
||||
{
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
|
||||
|
@ -1436,7 +1641,8 @@ var TextureTintPipeline = new Class({
|
|||
getTint(text._tintBL, text._alphaBL),
|
||||
getTint(text._tintBR, text._alphaBR),
|
||||
0, 0,
|
||||
camera
|
||||
camera,
|
||||
parentTransformMatrix
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -1448,8 +1654,9 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchDynamicTilemapLayer: function (tilemapLayer, camera)
|
||||
batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix)
|
||||
{
|
||||
var renderTiles = tilemapLayer.culledTiles;
|
||||
var length = renderTiles.length;
|
||||
|
@ -1491,7 +1698,8 @@ var TextureTintPipeline = new Class({
|
|||
frameX, frameY, frameWidth, frameHeight,
|
||||
tint, tint, tint, tint,
|
||||
0, 0,
|
||||
camera
|
||||
camera,
|
||||
parentTransformMatrix
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -1504,8 +1712,9 @@ var TextureTintPipeline = new Class({
|
|||
*
|
||||
* @param {Phaser.GameObjects.TileSprite} tileSprite - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchTileSprite: function (tileSprite, camera)
|
||||
batchTileSprite: function (tileSprite, camera, parentTransformMatrix)
|
||||
{
|
||||
var getTint = Utils.getTintAppendFloatAlpha;
|
||||
|
||||
|
@ -1525,9 +1734,10 @@ var TextureTintPipeline = new Class({
|
|||
getTint(tileSprite._tintTR, tileSprite._alphaTR),
|
||||
getTint(tileSprite._tintBL, tileSprite._alphaBL),
|
||||
getTint(tileSprite._tintBR, tileSprite._alphaBR),
|
||||
tileSprite.tilePositionX / tileSprite.frame.width,
|
||||
tileSprite.tilePositionY / tileSprite.frame.height,
|
||||
camera
|
||||
(tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width,
|
||||
(tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height,
|
||||
camera,
|
||||
parentTransformMatrix
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -1565,6 +1775,7 @@ var TextureTintPipeline = new Class({
|
|||
* @param {float} uOffset - [description]
|
||||
* @param {float} vOffset - [description]
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*/
|
||||
batchTexture: function (
|
||||
gameObject,
|
||||
|
@ -1580,8 +1791,16 @@ var TextureTintPipeline = new Class({
|
|||
frameX, frameY, frameWidth, frameHeight,
|
||||
tintTL, tintTR, tintBL, tintBR,
|
||||
uOffset, vOffset,
|
||||
camera)
|
||||
camera,
|
||||
parentTransformMatrix)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
if (this.vertexCount + 6 > this.vertexCapacity)
|
||||
|
@ -1618,12 +1837,39 @@ var TextureTintPipeline = new Class({
|
|||
var cmd = cameraMatrix[3];
|
||||
var cme = cameraMatrix[4];
|
||||
var cmf = cameraMatrix[5];
|
||||
var mva = sra * cma + srb * cmc;
|
||||
var mvb = sra * cmb + srb * cmd;
|
||||
var mvc = src * cma + srd * cmc;
|
||||
var mvd = src * cmb + srd * cmd;
|
||||
var mve = sre * cma + srf * cmc + cme;
|
||||
var mvf = sre * cmb + srf * cmd + cmf;
|
||||
var mva, mvb, mvc, mvd, mve, mvf;
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = cma * pma + cmb * pmc;
|
||||
var pcb = cma * pmb + cmb * pmd;
|
||||
var pcc = cmc * pma + cmd * pmc;
|
||||
var pcd = cmc * pmb + cmd * pmd;
|
||||
var pce = cme * pma + cmf * pmc + pme;
|
||||
var pcf = cme * pmb + cmf * pmd + pmf;
|
||||
mva = sra * pca + srb * pcc;
|
||||
mvb = sra * pcb + srb * pcd;
|
||||
mvc = src * pca + srd * pcc;
|
||||
mvd = src * pcb + srd * pcd;
|
||||
mve = sre * pca + srf * pcc + pce;
|
||||
mvf = sre * pcb + srf * pcd + pcf;
|
||||
}
|
||||
else
|
||||
{
|
||||
mva = sra * cma + srb * cmc;
|
||||
mvb = sra * cmb + srb * cmd;
|
||||
mvc = src * cma + srd * cmc;
|
||||
mvd = src * cmb + srd * cmd;
|
||||
mve = sre * cma + srf * cmc + cme;
|
||||
mvf = sre * cmb + srf * cmd + cmf;
|
||||
}
|
||||
|
||||
var tx0 = x * mva + y * mvc + mve;
|
||||
var ty0 = x * mvb + y * mvd + mvf;
|
||||
var tx1 = x * mva + yh * mvc + mve;
|
||||
|
@ -1704,6 +1950,7 @@ var TextureTintPipeline = new Class({
|
|||
* @param {number} frameWidth - [description]
|
||||
* @param {number} frameHeight - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - [description]
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
|
||||
*
|
||||
* @return {Phaser.Renderer.WebGL.TextureTintPipeline} This Pipeline.
|
||||
*/
|
||||
|
@ -1712,9 +1959,17 @@ var TextureTintPipeline = new Class({
|
|||
srcX, srcY,
|
||||
tint, alpha,
|
||||
frameX, frameY, frameWidth, frameHeight,
|
||||
transformMatrix
|
||||
transformMatrix,
|
||||
parentTransformMatrix
|
||||
)
|
||||
{
|
||||
var parentMatrix = null;
|
||||
|
||||
if (parentTransformMatrix)
|
||||
{
|
||||
parentMatrix = parentTransformMatrix.matrix;
|
||||
}
|
||||
|
||||
this.renderer.setPipeline(this);
|
||||
|
||||
if (this.vertexCount + 6 > this.vertexCapacity)
|
||||
|
@ -1737,6 +1992,29 @@ var TextureTintPipeline = new Class({
|
|||
var mvd = transformMatrix[3];
|
||||
var mve = transformMatrix[4];
|
||||
var mvf = transformMatrix[5];
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
var pma = parentMatrix[0];
|
||||
var pmb = parentMatrix[1];
|
||||
var pmc = parentMatrix[2];
|
||||
var pmd = parentMatrix[3];
|
||||
var pme = parentMatrix[4];
|
||||
var pmf = parentMatrix[5];
|
||||
var pca = mva * pma + mvb * pmc;
|
||||
var pcb = mva * pmb + mvb * pmd;
|
||||
var pcc = mvc * pma + mvd * pmc;
|
||||
var pcd = mvc * pmb + mvd * pmd;
|
||||
var pce = mve * pma + mvf * pmc + pme;
|
||||
var pcf = mve * pmb + mvf * pmd + pmf;
|
||||
mva = pca;
|
||||
mvb = pcb;
|
||||
mvc = pcc;
|
||||
mvd = pcd;
|
||||
mve = pce;
|
||||
mvf = pcf;
|
||||
}
|
||||
|
||||
var tx0 = x * mva + y * mvc + mve;
|
||||
var ty0 = x * mvb + y * mvd + mvf;
|
||||
var tx1 = x * mva + yh * mvc + mve;
|
||||
|
|
|
@ -5,8 +5,14 @@
|
|||
*/
|
||||
|
||||
// These properties get injected into the Scene and map to local systems
|
||||
// The map key is the property that is added to the Scene, the value is the Scene.Systems reference
|
||||
// The map value is the property that is injected into the Scene, the key is the Scene.Systems reference.
|
||||
// These defaults can be modified via the Scene config object
|
||||
// var config = {
|
||||
// map: {
|
||||
// add: 'makeStuff',
|
||||
// load: 'loader'
|
||||
// }
|
||||
// };
|
||||
|
||||
var InjectionMap = {
|
||||
|
||||
|
|
|
@ -32,6 +32,226 @@ var Scene = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.sys = new Systems(this, config);
|
||||
|
||||
/**
|
||||
* A reference to the Phaser.Game instance.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#game
|
||||
* @type {Phaser.Game}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.game;
|
||||
|
||||
/**
|
||||
* A reference to the global Animation Manager.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#anims
|
||||
* @type {Phaser.Animations.AnimationManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.anims;
|
||||
|
||||
/**
|
||||
* A reference to the global Cache.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#cache
|
||||
* @type {Phaser.Cache.CacheManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cache;
|
||||
|
||||
/**
|
||||
* A reference to the game level Data Manager.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#registry
|
||||
* @type {Phaser.Data.DataManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.registry;
|
||||
|
||||
/**
|
||||
* A reference to the Sound Manager.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#sound
|
||||
* @type {Phaser.Sound.BaseSoundManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.sound;
|
||||
|
||||
/**
|
||||
* A reference to the Texture Manager.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#textures
|
||||
* @type {Phaser.Textures.TextureManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.textures;
|
||||
|
||||
/**
|
||||
* A scene level Event Emitter.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#events
|
||||
* @type {Phaser.Events.EventEmitter}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.events;
|
||||
|
||||
/**
|
||||
* A scene level Camera System.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#cameras
|
||||
* @type {Phaser.Cameras.Scene2D.CameraManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cameras;
|
||||
|
||||
/**
|
||||
* A scene level 3D Camera System.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#cameras3d
|
||||
* @type {Phaser.Cameras.Sprite3D.CameraManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cameras3d;
|
||||
|
||||
/**
|
||||
* A scene level Game Object Factory.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#add
|
||||
* @type {Phaser.GameObjects.GameObjectFactory}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.add;
|
||||
|
||||
/**
|
||||
* A scene level Game Object Creator.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#make
|
||||
* @type {Phaser.GameObjects.GameObjectCreator}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.make;
|
||||
|
||||
/**
|
||||
* A reference to the Scene Manager Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#scene
|
||||
* @type {Phaser.Scenes.ScenePlugin}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene;
|
||||
|
||||
/**
|
||||
* A scene level Game Object Display List.
|
||||
* This property will only be available if defined in the Scene Injection Map.
|
||||
*
|
||||
* @name Phaser.Scene#children
|
||||
* @type {Phaser.GameObjects.DisplayList}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.children;
|
||||
|
||||
/**
|
||||
* A scene level Lights Manager Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#lights
|
||||
* @type {Phaser.GameObjects.DisplayList}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.lights;
|
||||
|
||||
/**
|
||||
* A scene level Data Manager Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#data
|
||||
* @type {Phaser.Data.DataManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.data;
|
||||
|
||||
/**
|
||||
* A scene level Input Manager Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#input
|
||||
* @type {Phaser.Input.InputPlugin}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.input;
|
||||
|
||||
/**
|
||||
* A scene level Loader Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#load
|
||||
* @type {Phaser.Loader.LoaderPlugin}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.load;
|
||||
|
||||
/**
|
||||
* A scene level Time and Clock Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#time
|
||||
* @type {Phaser.Time.Clock}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.time;
|
||||
|
||||
/**
|
||||
* A scene level Tween Manager Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map and the plugin is installed.
|
||||
*
|
||||
* @name Phaser.Scene#tweens
|
||||
* @type {Phaser.Tweens.TweenManager}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.tweens;
|
||||
|
||||
/**
|
||||
* A scene level Arcade Physics Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.
|
||||
*
|
||||
* @name Phaser.Scene#physics
|
||||
* @type {Phaser.Physics.Arcade.ArcadePhysics}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.physics;
|
||||
|
||||
/**
|
||||
* A scene level Impact Physics Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.
|
||||
*
|
||||
* @name Phaser.Scene#impact
|
||||
* @type {Phaser.Physics.Impact.ImpactPhysics}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.impact;
|
||||
|
||||
/**
|
||||
* A scene level Matter Physics Plugin.
|
||||
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.
|
||||
*
|
||||
* @name Phaser.Scene#matter
|
||||
* @type {Phaser.Physics.Matter.MatterPhysics}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.matter;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -40,6 +260,9 @@ var Scene = new Class({
|
|||
* @method Phaser.Scene#update
|
||||
* @override
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ var SceneManager = new Class({
|
|||
function SceneManager (game, sceneConfig)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The Game that this SceneManager belongs to.
|
||||
*
|
||||
* @name Phaser.Scenes.SceneManager#game
|
||||
* @type {Phaser.Game}
|
||||
|
@ -180,14 +180,14 @@ var SceneManager = new Class({
|
|||
{
|
||||
entry = this._start[i];
|
||||
|
||||
this.start(entry);
|
||||
this.start(entry, entry.scene.data);
|
||||
}
|
||||
|
||||
this._start.length = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Process the Scene operations queue.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#processQueue
|
||||
* @since 3.0.0
|
||||
|
@ -219,7 +219,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
entry = this._start[i];
|
||||
|
||||
this.start(entry);
|
||||
this.start(entry, entry.scene.data);
|
||||
}
|
||||
|
||||
// Clear the pending lists
|
||||
|
@ -257,10 +257,10 @@ var SceneManager = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`.
|
||||
* @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description]
|
||||
* @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - The config for the Scene
|
||||
* @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added.
|
||||
*
|
||||
* @return {?Phaser.Scene} [description]
|
||||
* @return {?Phaser.Scene} The added Scene, if it was added immediately.
|
||||
*/
|
||||
add: function (key, sceneConfig, autoStart)
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
if (this.game.isBooted)
|
||||
{
|
||||
this.start(key);
|
||||
this.start(key, newScene.sys.settings.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -373,13 +373,13 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Boot the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#bootScene
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {Phaser.Scene} scene - The Scene to boot.
|
||||
*/
|
||||
bootScene: function (scene)
|
||||
{
|
||||
|
@ -424,13 +424,15 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Handles load completion for a Scene's Loader.
|
||||
*
|
||||
* Starts the Scene that the Loader belongs to.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#loadComplete
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Loader.LoaderPlugin} loader - [description]
|
||||
* @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading.
|
||||
*/
|
||||
loadComplete: function (loader)
|
||||
{
|
||||
|
@ -440,13 +442,13 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Handle payload completion for a Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#payloadComplete
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Loader.LoaderPlugin} loader - [description]
|
||||
* @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading its Scene's payload.
|
||||
*/
|
||||
payloadComplete: function (loader)
|
||||
{
|
||||
|
@ -454,13 +456,13 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Updates the Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
* @param {number} time - Time elapsed.
|
||||
* @param {number} delta - Delta time from the last update.
|
||||
*/
|
||||
update: function (time, delta)
|
||||
{
|
||||
|
@ -481,7 +483,7 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Informs the Scenes of the Game being resized.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#resize
|
||||
* @since 3.2.0
|
||||
|
@ -501,12 +503,12 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Renders the Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#render
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {*} renderer - [description]
|
||||
* @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer to use.
|
||||
*/
|
||||
render: function (renderer)
|
||||
{
|
||||
|
@ -525,13 +527,13 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Calls the given Scene's {@link Phaser.Scene#create} method and updates its status.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#create
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {Phaser.Scene} scene - The Scene to create.
|
||||
*/
|
||||
create: function (scene)
|
||||
{
|
||||
|
@ -546,16 +548,16 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates and initializes a Scene from a function.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#createSceneFromFunction
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {function} scene - [description]
|
||||
* @param {string} key - The key of the Scene.
|
||||
* @param {function} scene - The function to create the Scene from.
|
||||
*
|
||||
* @return {Phaser.Scene} [description]
|
||||
* @return {Phaser.Scene} The created Scene.
|
||||
*/
|
||||
createSceneFromFunction: function (key, scene)
|
||||
{
|
||||
|
@ -595,16 +597,16 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates and initializes a Scene instance.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#createSceneFromInstance
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {Phaser.Scene} newScene - [description]
|
||||
* @param {string} key - The key of the Scene.
|
||||
* @param {Phaser.Scene} newScene - The Scene instance.
|
||||
*
|
||||
* @return {Phaser.Scene} [description]
|
||||
* @return {Phaser.Scene} The created Scene.
|
||||
*/
|
||||
createSceneFromInstance: function (key, newScene)
|
||||
{
|
||||
|
@ -625,16 +627,16 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates and initializes a Scene from an Object definition.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#createSceneFromObject
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {(string|SettingsConfig)} sceneConfig - [description]
|
||||
* @param {string} key - The key of the Scene.
|
||||
* @param {(string|SettingsConfig)} sceneConfig - The Scene config.
|
||||
*
|
||||
* @return {Phaser.Scene} [description]
|
||||
* @return {Phaser.Scene} The created Scene.
|
||||
*/
|
||||
createSceneFromObject: function (key, sceneConfig)
|
||||
{
|
||||
|
@ -695,20 +697,25 @@ var SceneManager = new Class({
|
|||
}
|
||||
}
|
||||
|
||||
if (sceneConfig.hasOwnProperty('data'))
|
||||
{
|
||||
newScene.data = sceneConfig.data;
|
||||
}
|
||||
|
||||
return newScene;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieves the key of a Scene from a Scene config.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#getKey
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description]
|
||||
* @param {string} key - The key to check in the Scene config.
|
||||
* @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - The Scene config.
|
||||
*
|
||||
* @return {string} [description]
|
||||
* @return {string} The Scene key.
|
||||
*/
|
||||
getKey: function (key, sceneConfig)
|
||||
{
|
||||
|
@ -740,14 +747,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieves a Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#getScene
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to retrieve.
|
||||
*
|
||||
* @return {?Phaser.Scene} [description]
|
||||
* @return {?Phaser.Scene} The Scene.
|
||||
*/
|
||||
getScene: function (key)
|
||||
{
|
||||
|
@ -773,14 +780,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Determines whether a Scene is active.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#isActive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is active.
|
||||
*/
|
||||
isActive: function (key)
|
||||
{
|
||||
|
@ -795,14 +802,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Determines whether a Scene is visible.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#isVisible
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is visible.
|
||||
*/
|
||||
isVisible: function (key)
|
||||
{
|
||||
|
@ -817,14 +824,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Determines whether a Scene is sleeping.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#isSleeping
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is sleeping.
|
||||
*/
|
||||
isSleeping: function (key)
|
||||
{
|
||||
|
@ -839,14 +846,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Pauses the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#pause
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to pause.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
pause: function (key)
|
||||
{
|
||||
|
@ -861,14 +868,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Resumes the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#resume
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to resume.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
resume: function (key)
|
||||
{
|
||||
|
@ -883,14 +890,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Puts the given Scene to sleep.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#sleep
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to put to sleep.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
sleep: function (key)
|
||||
{
|
||||
|
@ -905,14 +912,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Awakens the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#wake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to wake up.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
wake: function (key)
|
||||
{
|
||||
|
@ -927,21 +934,21 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Starts the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {object} [data] - [description]
|
||||
* @param {string} key - The Scene to start.
|
||||
* @param {object} [data] - The Scene data.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
start: function (key, data)
|
||||
{
|
||||
if (data === undefined) { data = {}; }
|
||||
|
||||
// if not booted, then put scene into a holding pattern
|
||||
// If the Game is not booted, then put the Scene into a holding pattern
|
||||
if (!this.game.isBooted)
|
||||
{
|
||||
for (var i = 0; i < this._pending.length; i++)
|
||||
|
@ -951,7 +958,7 @@ var SceneManager = new Class({
|
|||
if (entry.key === key)
|
||||
{
|
||||
entry.autoStart = true;
|
||||
entry.data = data;
|
||||
entry.scene.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,14 +1002,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Stops the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#stop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to stop.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
stop: function (key)
|
||||
{
|
||||
|
@ -1017,15 +1024,15 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sleeps one one Scene and starts the other.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#switch
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} from - [description]
|
||||
* @param {string} to - [description]
|
||||
* @param {string} from - The Scene to sleep.
|
||||
* @param {string} to - The Scene to start.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
switch: function (from, to)
|
||||
{
|
||||
|
@ -1050,14 +1057,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieves a Scene by numeric index.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#getAt
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} index - [description]
|
||||
* @param {integer} index - The index of the Scene to retrieve.
|
||||
*
|
||||
* @return {(Phaser.Scene|undefined)} [description]
|
||||
* @return {(Phaser.Scene|undefined)} The Scene.
|
||||
*/
|
||||
getAt: function (index)
|
||||
{
|
||||
|
@ -1065,14 +1072,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieves the numeric index of a Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#getIndex
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} key - [description]
|
||||
* @param {(string|Phaser.Scene)} key - The key of the Scene.
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @return {integer} The index of the Scene.
|
||||
*/
|
||||
getIndex: function (key)
|
||||
{
|
||||
|
@ -1082,14 +1089,16 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Brings a Scene to the top of the Scenes list.
|
||||
*
|
||||
* This means it will render above all other Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#bringToTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} key - [description]
|
||||
* @param {(string|Phaser.Scene)} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
bringToTop: function (key)
|
||||
{
|
||||
|
@ -1114,14 +1123,16 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sends a Scene to the back of the Scenes list.
|
||||
*
|
||||
* This means it will render below all other Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#sendToBack
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} key - [description]
|
||||
* @param {(string|Phaser.Scene)} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
sendToBack: function (key)
|
||||
{
|
||||
|
@ -1146,14 +1157,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Moves a Scene down one position in the Scenes list.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveDown
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} key - [description]
|
||||
* @param {(string|Phaser.Scene)} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
moveDown: function (key)
|
||||
{
|
||||
|
@ -1180,14 +1191,14 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Moves a Scene up one position in the Scenes list.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveUp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} key - [description]
|
||||
* @param {(string|Phaser.Scene)} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
moveUp: function (key)
|
||||
{
|
||||
|
@ -1215,6 +1226,7 @@ var SceneManager = new Class({
|
|||
|
||||
/**
|
||||
* Moves a Scene so it is immediately above another Scene in the Scenes list.
|
||||
*
|
||||
* This means it will render over the top of the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveAbove
|
||||
|
@ -1223,7 +1235,7 @@ var SceneManager = new Class({
|
|||
* @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {(string|Phaser.Scene)} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
moveAbove: function (keyA, keyB)
|
||||
{
|
||||
|
@ -1258,6 +1270,7 @@ var SceneManager = new Class({
|
|||
|
||||
/**
|
||||
* Moves a Scene so it is immediately below another Scene in the Scenes list.
|
||||
*
|
||||
* This means it will render behind the other Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#moveBelow
|
||||
|
@ -1266,7 +1279,7 @@ var SceneManager = new Class({
|
|||
* @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above.
|
||||
* @param {(string|Phaser.Scene)} keyB - The Scene to be moved.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
moveBelow: function (keyA, keyB)
|
||||
{
|
||||
|
@ -1307,15 +1320,15 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Swaps the positions of two Scenes in the Scenes list.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#swapPosition
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} keyA - [description]
|
||||
* @param {(string|Phaser.Scene)} keyB - [description]
|
||||
* @param {(string|Phaser.Scene)} keyA - The first Scene to swap.
|
||||
* @param {(string|Phaser.Scene)} keyB - The second Scene to swap.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} [description]
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
swapPosition: function (keyA, keyB)
|
||||
{
|
||||
|
@ -1345,6 +1358,12 @@ var SceneManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Dumps debug information about each Scene to the developer console.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#dump
|
||||
* @since 3.2.0
|
||||
*/
|
||||
dump: function ()
|
||||
{
|
||||
var out = [];
|
||||
|
@ -1364,7 +1383,7 @@ var SceneManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroy the SceneManager and all of its Scene's systems.
|
||||
*
|
||||
* @method Phaser.Scenes.SceneManager#destroy
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -17,7 +17,7 @@ var PluginManager = require('../boot/PluginManager');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {Phaser.Scene} scene - The Scene that this ScenePlugin belongs to.
|
||||
*/
|
||||
var ScenePlugin = new Class({
|
||||
|
||||
|
@ -26,7 +26,7 @@ var ScenePlugin = new Class({
|
|||
function ScenePlugin (scene)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that this ScenePlugin belongs to.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#scene
|
||||
* @type {Phaser.Scene}
|
||||
|
@ -35,7 +35,7 @@ var ScenePlugin = new Class({
|
|||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene Systems instance of the Scene that this ScenePlugin belongs to.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#systems
|
||||
* @type {Phaser.Scenes.Systems}
|
||||
|
@ -49,7 +49,7 @@ var ScenePlugin = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The settings of the Scene this ScenePlugin belongs to.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#settings
|
||||
* @type {SettingsObject}
|
||||
|
@ -58,7 +58,7 @@ var ScenePlugin = new Class({
|
|||
this.settings = scene.sys.settings;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The key of the Scene this ScenePlugin belongs to.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#key
|
||||
* @type {string}
|
||||
|
@ -67,7 +67,7 @@ var ScenePlugin = new Class({
|
|||
this.key = scene.sys.settings.key;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Game's SceneManager.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#manager
|
||||
* @type {Phaser.Scenes.SceneManager}
|
||||
|
@ -77,7 +77,9 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Boot the ScenePlugin.
|
||||
*
|
||||
* Registers event handlers.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#boot
|
||||
* @since 3.0.0
|
||||
|
@ -96,8 +98,8 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {object} [data] - [description]
|
||||
* @param {string} key - The Scene to start.
|
||||
* @param {object} [data] - The Scene data.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -125,9 +127,9 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {object} sceneConfig - [description]
|
||||
* @param {boolean} autoStart - [description]
|
||||
* @param {string} key - The Scene key.
|
||||
* @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - The config for the Scene.
|
||||
* @param {boolean} autoStart - Whether to start the Scene after it's added.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -144,8 +146,8 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#launch
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {object} [data] - [description]
|
||||
* @param {string} key - The Scene to launch.
|
||||
* @param {object} [data] - The Scene data.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -172,7 +174,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#pause
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to pause.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -191,7 +193,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#resume
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to resume.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -210,7 +212,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#sleep
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to put to sleep.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -229,7 +231,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#wake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to wake up.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -248,7 +250,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#switch
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to start.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -275,7 +277,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#stop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to stop.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -294,7 +296,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#setActive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} value - [description]
|
||||
* @param {boolean} value - The Scene to set the active state for.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -311,7 +313,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#setVisible
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} value - [description]
|
||||
* @param {boolean} value - The Scene to set the visible state for.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -328,9 +330,9 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#isSleeping
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is sleeping.
|
||||
*/
|
||||
isSleeping: function (key)
|
||||
{
|
||||
|
@ -345,9 +347,9 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#isActive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is active.
|
||||
*/
|
||||
isActive: function (key)
|
||||
{
|
||||
|
@ -362,9 +364,9 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#isVisible
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to check.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Whether the Scene is visible.
|
||||
*/
|
||||
isVisible: function (key)
|
||||
{
|
||||
|
@ -375,6 +377,7 @@ var ScenePlugin = new Class({
|
|||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list.
|
||||
*
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#swapPosition
|
||||
|
@ -399,6 +402,7 @@ var ScenePlugin = new Class({
|
|||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A.
|
||||
*
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveAbove
|
||||
|
@ -423,6 +427,7 @@ var ScenePlugin = new Class({
|
|||
|
||||
/**
|
||||
* Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A.
|
||||
*
|
||||
* This controls the order in which they are rendered and updated.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveBelow
|
||||
|
@ -457,7 +462,7 @@ var ScenePlugin = new Class({
|
|||
* @method Phaser.Scenes.ScenePlugin#remove
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {(string|Phaser.Scene)} scene - The Scene to be removed.
|
||||
* @param {(string|Phaser.Scene)} key - The Scene to be removed.
|
||||
*
|
||||
* @return {Phaser.Scenes.SceneManager} This SceneManager.
|
||||
*/
|
||||
|
@ -471,12 +476,12 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Moves a Scene up one position in the Scenes list.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveUp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -490,12 +495,12 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Moves a Scene down one position in the Scenes list.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#moveDown
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -509,12 +514,14 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Brings a Scene to the top of the Scenes list.
|
||||
*
|
||||
* This means it will render above all other Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#bringToTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -528,12 +535,14 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sends a Scene to the back of the Scenes list.
|
||||
*
|
||||
* This means it will render below all other Scenes.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#sendToBack
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to move.
|
||||
*
|
||||
* @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object.
|
||||
*/
|
||||
|
@ -547,14 +556,14 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Retrieve a Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#get
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The Scene to retrieve.
|
||||
*
|
||||
* @return {Phaser.Scene} [description]
|
||||
* @return {Phaser.Scene} The Scene.
|
||||
*/
|
||||
get: function (key)
|
||||
{
|
||||
|
@ -562,7 +571,7 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Shut down the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#shutdown
|
||||
* @since 3.0.0
|
||||
|
@ -573,7 +582,7 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroy the given Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#destroy
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -167,7 +167,7 @@ var Systems = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @name Phaser.Scenes.Systems#displayList
|
||||
* @type {null}
|
||||
* @type {Phaser.GameObjects.DisplayList}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.displayList;
|
||||
|
|
|
@ -12,7 +12,7 @@ var NOOP = require('../utils/NOOP');
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* Class containing all the shared state and behaviour of a sound object, independent of the implementation.
|
||||
* Class containing all the shared state and behavior of a sound object, independent of the implementation.
|
||||
*
|
||||
* @class BaseSound
|
||||
* @extends Phaser.Events.EventEmitter
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
var Class = require('../utils/Class');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
|
||||
/**
|
||||
* @callback EachListCallback
|
||||
|
@ -63,6 +64,24 @@ var List = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.position = 0;
|
||||
|
||||
/**
|
||||
* A callback that is invoked every time a child is added to this list.
|
||||
*
|
||||
* @name Phaser.Structs.List#addCallback
|
||||
* @type {function}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.addCallback = NOOP;
|
||||
|
||||
/**
|
||||
* A callback that is invoked every time a child is removed from this list.
|
||||
*
|
||||
* @name Phaser.Structs.List#removeCallback
|
||||
* @type {function}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.removeCallback = NOOP;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -73,20 +92,33 @@ var List = new Class({
|
|||
*
|
||||
* @genericUse {T} - [child,$return]
|
||||
*
|
||||
* @param {*} child - [description]
|
||||
* @param {*|Array.<*>} child - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully.
|
||||
*
|
||||
* @return {*} [description]
|
||||
*/
|
||||
add: function (child)
|
||||
add: function (child, skipCallback)
|
||||
{
|
||||
// Is child already in this display list?
|
||||
|
||||
if (this.getIndex(child) === -1)
|
||||
if (Array.isArray(child))
|
||||
{
|
||||
this.list.push(child);
|
||||
return this.addMultiple(child, skipCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is child already in this display list?
|
||||
|
||||
return child;
|
||||
if (this.getIndex(child) === -1)
|
||||
{
|
||||
this.list.push(child);
|
||||
|
||||
if (!skipCallback)
|
||||
{
|
||||
this.addCallback(this, child);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -99,16 +131,17 @@ var List = new Class({
|
|||
*
|
||||
* @param {*} child - [description]
|
||||
* @param {integer} [index=0] - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully.
|
||||
*
|
||||
* @return {*} [description]
|
||||
*/
|
||||
addAt: function (child, index)
|
||||
addAt: function (child, index, skipCallback)
|
||||
{
|
||||
if (index === undefined) { index = 0; }
|
||||
|
||||
if (this.list.length === 0)
|
||||
{
|
||||
return this.add(child);
|
||||
return this.add(child, skipCallback);
|
||||
}
|
||||
|
||||
if (index >= 0 && index <= this.list.length)
|
||||
|
@ -116,6 +149,11 @@ var List = new Class({
|
|||
if (this.getIndex(child) === -1)
|
||||
{
|
||||
this.list.splice(index, 0, child);
|
||||
|
||||
if (!skipCallback)
|
||||
{
|
||||
this.addCallback(this, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,16 +169,17 @@ var List = new Class({
|
|||
* @genericUse {T[]} - [children,$return]
|
||||
*
|
||||
* @param {Array.<*>} children - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully.
|
||||
*
|
||||
* @return {Array.<*>} [description]
|
||||
*/
|
||||
addMultiple: function (children)
|
||||
addMultiple: function (children, skipCallback)
|
||||
{
|
||||
if (Array.isArray(children))
|
||||
{
|
||||
for (var i = 0; i < children.length; i++)
|
||||
{
|
||||
this.add(children[i]);
|
||||
this.add(children[i], skipCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,16 +534,22 @@ var List = new Class({
|
|||
* @genericUse {T} - [child,$return]
|
||||
*
|
||||
* @param {*} child - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback.
|
||||
*
|
||||
* @return {*} [description]
|
||||
*/
|
||||
remove: function (child)
|
||||
remove: function (child, skipCallback)
|
||||
{
|
||||
var index = this.list.indexOf(child);
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
this.list.splice(index, 1);
|
||||
|
||||
if (!skipCallback)
|
||||
{
|
||||
this.removeCallback(this, child);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -519,16 +564,22 @@ var List = new Class({
|
|||
* @genericUse {T} - [$return]
|
||||
*
|
||||
* @param {integer} index - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback.
|
||||
*
|
||||
* @return {*} [description]
|
||||
*/
|
||||
removeAt: function (index)
|
||||
removeAt: function (index, skipCallback)
|
||||
{
|
||||
var child = this.list[index];
|
||||
|
||||
if (child)
|
||||
{
|
||||
this.children.splice(index, 1);
|
||||
|
||||
if (!skipCallback)
|
||||
{
|
||||
this.removeCallback(this, child);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -544,10 +595,11 @@ var List = new Class({
|
|||
*
|
||||
* @param {integer} [beginIndex=0] - [description]
|
||||
* @param {integer} [endIndex] - [description]
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback.
|
||||
*
|
||||
* @return {Array.<*>} [description]
|
||||
*/
|
||||
removeBetween: function (beginIndex, endIndex)
|
||||
removeBetween: function (beginIndex, endIndex, skipCallback)
|
||||
{
|
||||
if (beginIndex === undefined) { beginIndex = 0; }
|
||||
if (endIndex === undefined) { endIndex = this.list.length; }
|
||||
|
@ -558,6 +610,11 @@ var List = new Class({
|
|||
{
|
||||
var removed = this.list.splice(beginIndex, range);
|
||||
|
||||
if (!skipCallback)
|
||||
{
|
||||
this.removeCallback(this, removed);
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
else if (range === 0 && this.list.length === 0)
|
||||
|
@ -577,16 +634,18 @@ var List = new Class({
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @genericUse {Phaser.Structs.List.<T>} - [$return]
|
||||
*
|
||||
* @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback.
|
||||
*
|
||||
* @return {Phaser.Structs.List} This List object.
|
||||
*/
|
||||
removeAll: function ()
|
||||
removeAll: function (skipCallback)
|
||||
{
|
||||
var i = this.list.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.remove(this.list[i]);
|
||||
this.remove(this.list[i], skipCallback);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -608,8 +667,8 @@ var List = new Class({
|
|||
{
|
||||
if (this.getIndex(child) < this.list.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
this.remove(child, true);
|
||||
this.add(child, true);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -631,8 +690,8 @@ var List = new Class({
|
|||
{
|
||||
if (this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
this.remove(child, true);
|
||||
this.addAt(child, 0, true);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
|
|
@ -11,7 +11,7 @@ var Class = require('../utils/Class');
|
|||
* @generic E - [entry]
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {E} entry - [description]
|
||||
* @param {*} entry - [description]
|
||||
*
|
||||
* @return {?boolean} [description]
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,13 @@ var GetFastValue = require('../../utils/object/GetFastValue');
|
|||
* @param {integer} y - [description]
|
||||
* @param {integer} width - [description]
|
||||
* @param {integer} height - [description]
|
||||
* @param {object} config - [description]
|
||||
* @param {object} config - An object describing how to parse the Sprite Sheet.
|
||||
* @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet.
|
||||
* @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.
|
||||
* @param {number} [config.startFrame=0] - [description]
|
||||
* @param {number} [config.endFrame=-1] - [description]
|
||||
* @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here.
|
||||
* @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
|
||||
*
|
||||
* @return {Phaser.Textures.Texture} The Texture modified by this parser.
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@ var GetFastValue = require('../../utils/object/GetFastValue');
|
|||
|
||||
/**
|
||||
* Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas.
|
||||
*
|
||||
*
|
||||
* In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact
|
||||
* same size and cannot be trimmed or rotated.
|
||||
*
|
||||
|
@ -18,7 +18,13 @@ var GetFastValue = require('../../utils/object/GetFastValue');
|
|||
*
|
||||
* @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to.
|
||||
* @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet.
|
||||
* @param {object} config - [description]
|
||||
* @param {object} config - An object describing how to parse the Sprite Sheet.
|
||||
* @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet.
|
||||
* @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.
|
||||
* @param {number} [config.startFrame=0] - [description]
|
||||
* @param {number} [config.endFrame=-1] - [description]
|
||||
* @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here.
|
||||
* @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
|
||||
*
|
||||
* @return {Phaser.Textures.Texture} The Texture modified by this parser.
|
||||
*/
|
||||
|
|
|
@ -231,7 +231,7 @@ var Tilemap = new Class({
|
|||
*
|
||||
* @param {string} tilesetName - The name of the tileset as specified in the map data.
|
||||
* @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If
|
||||
* `undefined` or `null` it will look for an image with a key matching the tileset parameter.
|
||||
* `undefined` or `null` it will look for an image with a key matching the tilesetName parameter.
|
||||
* @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not
|
||||
* given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled
|
||||
* JSON file.
|
||||
|
|
|
@ -28,16 +28,16 @@ var TilemapComponents = require('../components');
|
|||
*
|
||||
* @extends Phaser.GameObjects.Components.Alpha
|
||||
* @extends Phaser.GameObjects.Components.BlendMode
|
||||
* @extends Phaser.GameObjects.Components.ComputedSize
|
||||
* @extends Phaser.GameObjects.Components.Depth
|
||||
* @extends Phaser.GameObjects.Components.Flip
|
||||
* @extends Phaser.GameObjects.Components.GetBounds
|
||||
* @extends Phaser.GameObjects.Components.Origin
|
||||
* @extends Phaser.GameObjects.Components.Pipeline
|
||||
* @extends Phaser.GameObjects.Components.ScaleMode
|
||||
* @extends Phaser.GameObjects.Components.Size
|
||||
* @extends Phaser.GameObjects.Components.ScrollFactor
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.GameObjects.Components.Visible
|
||||
* @extends Phaser.GameObjects.Components.ScrollFactor
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of.
|
||||
|
@ -53,13 +53,13 @@ var DynamicTilemapLayer = new Class({
|
|||
Mixins: [
|
||||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.ComputedSize,
|
||||
Components.Depth,
|
||||
Components.Flip,
|
||||
Components.GetBounds,
|
||||
Components.Origin,
|
||||
Components.Pipeline,
|
||||
Components.ScaleMode,
|
||||
Components.Size,
|
||||
Components.Transform,
|
||||
Components.Visible,
|
||||
Components.ScrollFactor,
|
||||
|
|
|
@ -29,13 +29,13 @@ var Utils = require('../../renderer/webgl/Utils');
|
|||
*
|
||||
* @extends Phaser.GameObjects.Components.Alpha
|
||||
* @extends Phaser.GameObjects.Components.BlendMode
|
||||
* @extends Phaser.GameObjects.Components.ComputedSize
|
||||
* @extends Phaser.GameObjects.Components.Depth
|
||||
* @extends Phaser.GameObjects.Components.Flip
|
||||
* @extends Phaser.GameObjects.Components.GetBounds
|
||||
* @extends Phaser.GameObjects.Components.Origin
|
||||
* @extends Phaser.GameObjects.Components.Pipeline
|
||||
* @extends Phaser.GameObjects.Components.ScaleMode
|
||||
* @extends Phaser.GameObjects.Components.Size
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.GameObjects.Components.Visible
|
||||
* @extends Phaser.GameObjects.Components.ScrollFactor
|
||||
|
@ -54,13 +54,13 @@ var StaticTilemapLayer = new Class({
|
|||
Mixins: [
|
||||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.ComputedSize,
|
||||
Components.Depth,
|
||||
Components.Flip,
|
||||
Components.GetBounds,
|
||||
Components.Origin,
|
||||
Components.Pipeline,
|
||||
Components.ScaleMode,
|
||||
Components.Size,
|
||||
Components.Transform,
|
||||
Components.Visible,
|
||||
Components.ScrollFactor,
|
||||
|
@ -220,8 +220,8 @@ var StaticTilemapLayer = new Class({
|
|||
var tileset = this.tileset;
|
||||
var mapWidth = this.layer.width;
|
||||
var mapHeight = this.layer.height;
|
||||
var width = tileset.image.get().width;
|
||||
var height = tileset.image.get().height;
|
||||
var width = tileset.image.source[0].width;
|
||||
var height = tileset.image.source[0].height;
|
||||
var mapData = this.layer.data;
|
||||
var renderer = this.renderer;
|
||||
var tile;
|
||||
|
|
|
@ -12,31 +12,64 @@
|
|||
*
|
||||
* @param {number} value - The value to search for in the array.
|
||||
* @param {array} array - The array to search, which must be sorted.
|
||||
* @param {string} [key] - An optional property key. If specified the array elements property will be checked against value.
|
||||
*
|
||||
* @return {number} The nearest value found in the array.
|
||||
* @return {number|object} The nearest value found in the array, or if a `key` was given, the nearest object with the matching property value.
|
||||
*/
|
||||
var FindClosestInSorted = function (value, array)
|
||||
var FindClosestInSorted = function (value, array, key)
|
||||
{
|
||||
if (!array.length)
|
||||
{
|
||||
return NaN;
|
||||
}
|
||||
else if (array.length === 1 || value < array[0])
|
||||
else if (array.length === 1)
|
||||
{
|
||||
return array[0];
|
||||
}
|
||||
|
||||
var i = 1;
|
||||
var low;
|
||||
var high;
|
||||
|
||||
while (array[i] < value)
|
||||
if (key)
|
||||
{
|
||||
i++;
|
||||
if (value < array[0][key])
|
||||
{
|
||||
return array[0];
|
||||
}
|
||||
|
||||
while (array[i][key] < value)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (array[i] < value)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
var low = array[i - 1];
|
||||
var high = (i < array.length) ? array[i] : Number.POSITIVE_INFINITY;
|
||||
if (i > array.length)
|
||||
{
|
||||
i = array.length;
|
||||
}
|
||||
|
||||
return ((high - value) <= (value - low)) ? high : low;
|
||||
if (key)
|
||||
{
|
||||
low = array[i - 1][key];
|
||||
high = array[i][key];
|
||||
|
||||
return ((high - value) <= (value - low)) ? array[i] : array[i - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
low = array[i - 1];
|
||||
high = array[i];
|
||||
|
||||
return ((high - value) <= (value - low)) ? high : low;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FindClosestInSorted;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
* @function Phaser.Utils.Object.Clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} obj - [description]
|
||||
* @param {object} obj - the object from which to clone
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {object} a new object with the same properties as the input obj
|
||||
*/
|
||||
var Clone = function (obj)
|
||||
{
|
||||
|
|
|
@ -4,21 +4,17 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
// Source object
|
||||
// The key as a string, can only be 1 level deep (no periods), must exist at the top level of the source object
|
||||
// The default value to use if the key doesn't exist
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Finds the key within the top level of the {@link source} object, or returns {@link defaultValue}
|
||||
*
|
||||
* @function Phaser.Utils.Object.GetFastValue
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} source - [description]
|
||||
* @param {string} key - [description]
|
||||
* @param {*} [defaultValue] - [description]
|
||||
* @param {object} source - The object to search
|
||||
* @param {string} key - The key for the property on source. Must exist at the top level of the source object (no periods)
|
||||
* @param {*} [defaultValue] - The default value to use if the key does not exist.
|
||||
*
|
||||
* @return {*} [description]
|
||||
* @return {*} The value if found; otherwise, defaultValue (null if none provided)
|
||||
*/
|
||||
var GetFastValue = function (source, key, defaultValue)
|
||||
{
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Verifies that an object contains all requested keys
|
||||
*
|
||||
* @function Phaser.Utils.Object.HasAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} source - [description]
|
||||
* @param {string[]} keys - [description]
|
||||
* @param {object} source - an object on which to check for key existence
|
||||
* @param {string[]} keys - an array of keys to ensure the source object contains
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} true if the source object contains all keys, false otherwise.
|
||||
*/
|
||||
var HasAll = function (source, keys)
|
||||
{
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Verifies that an object contains at least one of the requested keys
|
||||
*
|
||||
* @function Phaser.Utils.Object.HasAny
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} source - [description]
|
||||
* @param {string[]} keys - [description]
|
||||
* @param {object} source - an object on which to check for key existence
|
||||
* @param {string[]} keys - an array of keys to search the object for
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} true if the source object contains at least one of the keys, false otherwise
|
||||
*/
|
||||
var HasAny = function (source, keys)
|
||||
{
|
||||
|
|
|
@ -5,14 +5,23 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Capitalizes the first letter of a string if there is one.
|
||||
* @example
|
||||
* UppercaseFirst('abc');
|
||||
* // returns 'Abc'
|
||||
* @example
|
||||
* UppercaseFirst('the happy family');
|
||||
* // returns 'The happy family'
|
||||
* @example
|
||||
* UppercaseFirst('');
|
||||
* // returns ''
|
||||
*
|
||||
* @function Phaser.Utils.String.UppercaseFirst
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} str - [description]
|
||||
* @param {string} str - The string to capitalize.
|
||||
*
|
||||
* @return {string} [description]
|
||||
* @return {string} A new string, same as the first, but with the first letter capitalized.
|
||||
*/
|
||||
var UppercaseFirst = function (str)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue