mirror of
https://github.com/photonstorm/phaser
synced 2025-02-25 11:57:19 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
fb15586c16
69 changed files with 37360 additions and 24572 deletions
68
CHANGELOG.md
68
CHANGELOG.md
|
@ -1,9 +1,71 @@
|
|||
# Change Log
|
||||
|
||||
## Version 3.4.0 - In Development
|
||||
## Version 3.5.0 - in development
|
||||
|
||||
### Changes to Cameras
|
||||
|
||||
* The Camera class and all Camera effects are now fully covered by 100% complete JS Docs.
|
||||
* All Camera effects have been recoded from scratch. They now follow a unified effects structure and each effect is encapsulated in its own class found in the 'effects' folder. Currently there are Fade, Flash and Shake effects.
|
||||
* The new effects classes are accessed via the Camera properties `fadeEffect`, `flashEffect` and `shakeEffect`. You can still use the friendly Camera level methods: `shake`, `fade` and `flash`.
|
||||
* The new structure means you can replace the default effects with your own by simply overwriting the properties with your own class.
|
||||
* The effects now work properly under any combination. For example, you can fade out then in, or in then out, and still flash or shake while a fade is happening. The renderers now properly stack the effects in order to allow this.
|
||||
* All of the effect related Camera properties (like `_fadeAlpha`) have been removed. If you need access to these values you can get it much more cleanly via the camera effects classes themselves. They were always private anyway, but we know some of you needed to modify them, so have been doing so from your code. This code will now need updating.
|
||||
* Removed Camera.clearBeforeRender property as it was never used internally. This setting can be enabled on a Game-wide basis.
|
||||
* Camera now extends the Event Emitter, allowing it to emit events.
|
||||
* Camera.cullHitTest has been removed. It was never used internally and duplicates the code in `Camera.cull`.
|
||||
* The `callback` property of the Camera effects methods has changed purpose. It is no longer an `onComplete` callback, but is now an `onUpdate` callback. It is invoked every frame for the duration of the effect. See the docs for argument details.
|
||||
* Camera effects now dispatch events. They dispatch 'start' and 'complete' events, which can be used to handle any actions you may previously have been doing in the callback. See the effects docs and examples for the event names and arguments.
|
||||
* The Camera Shake effect now lets you specify a different intensities for the x and y dimensions.
|
||||
* You can track the progress of all events via the `progress` property on the effect instance, allowing you to sync effect duration with other in-game events.
|
||||
|
||||
### New Feature: Scene Transitions
|
||||
|
||||
There is a new method available in the ScenePlugin, available via: `this.scene.transition` which allows you to transition from one Scene to another over the duration specified. The method takes a configuration object which lets you control various aspects of the transition, from moving the Scenes around the display list, to specifying an onUpdate callback.
|
||||
|
||||
The calling Scene can be sent to sleep, stopped or removed entirely from the Scene Manager at the end of the transition, and you can even lock down input events in both Scenes while the transition is happening, if required. There are various events dispatched from both the calling and target Scene, which combined with the onUpdate callback give you the flexibility to create some truly impressive transition effects both into and out of Scenes.
|
||||
|
||||
Please see the complete JSDocs for the ScenePlugin for more details, as well as the new examples in the Phaser 3 Labs.
|
||||
|
||||
### More New Features
|
||||
|
||||
* GameObject.ignoreDestroy allows you to control if a Game Object is destroyed or not. Setting the flag will tell it to ignore destroy requests from Groups, Containers and even the Scene itself. See the docs for more details.
|
||||
* The Scene Input Plugin has a new property `enabled` which allows you to enable or disable input processing on per Scene basis.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* MatterEvents.off() would cause a TypeError if you destroyed the Matter world. Fix #3562 (thanks @pixelscripter)
|
||||
* DynamicBitmapText was missing the `letterSpacing` property, causing it to only render the first character in WebGL (thanks @Antriel)
|
||||
* The Animation component didn't properly check for the animation state in its update, causing pause / resume to fail. Fix #3556 (thanks @Antriel @siolfyr)
|
||||
* The Scene Manager would never reach an `isBooted` state if you didn't add any Scenes into the Game Config. Fix #3553 (thanks @rgk)
|
||||
* Fixed issue in HTMLAudioSound where `mute` would get into a recursive loop.
|
||||
* Every RenderTexture would draw the same content due to a mis-use of the CanvasPool (this also impacted TileSprites). Fix #3555 (thanks @kuoruan)
|
||||
* Group.add and Group.addMultiple now respect the Group.maxSize property, stopping you from over-populating a Group (thanks @samme)
|
||||
* When using HTML5 Audio, sound manager now tries to unlock audio after every scene loads, instead of only after first one. Fix #3309 (thanks @pavle-goloskokovic)
|
||||
* Group.createMultiple would insert null entries if the Group became full during the operation, causing errors later. Now it stops creating objects if the Group becomes full (thanks @samme)
|
||||
* Group.remove didn't check if the passed Game Object was already a member of the group and would call `removeCallback` and (if specified) `destroy` in any case. Now it does nothing if the Game Object isn't a member of the group (thanks @samme)
|
||||
* If a Group size exceeded `maxSize` (which can happen if you reduce maxSize beneath the current size), `isFull` would return false and the group could continue to grow. Now `isFull` returns true in that case (thanks @samme)
|
||||
* Camera.fadeIn following a fadeOut wouldn't work, but is now fixed as a result of the Camera effects rewrite. Fix #3527 (thanks @Jerenaux)
|
||||
|
||||
### Updates
|
||||
|
||||
* Removed the following properties from BaseSound as they are no longer required. Each class that extends BaseSound implements them directly as getters: `mute`, `loop`, `seek` and `volume`.
|
||||
* The Device.OS test to see if Phaser is running under node.js has been strengthened to support node-like environments like Vue (thanks @Chumper)
|
||||
* Every Plugin has been updated to correctly follow the same flow through the Scene lifecycle. Instead of listening for the Scene 'boot' event, which is only dispatched once (when the Scene is first created), they will now listen for the Scene 'start' event, which occurs every time the Scene is started. All plugins now consistently follow the same Shutdown and Destroy patterns too, meaning they tidy-up after themselves on a shutdown, not just a destroy. Overall, this change means that there should be less issues when returning to previously closed Scenes, as the plugins will restart themselves properly.
|
||||
* When shutting down a Scene all Game Objects that belong to the scene will now automatically destroy themselves. They would previously be removed from the display and update lists, but the objects themselves didn't self-destruct. You can control this on a per-object basis with the `ignoreDestroy` property.
|
||||
* A Matter Mouse Spring will disable debug draw of its constraint by default (you can override it by passing in your own config)
|
||||
|
||||
### 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:
|
||||
|
||||
@samme
|
||||
|
||||
## Version 3.4.0 - Miyako - 12th April 2018
|
||||
|
||||
### New Features
|
||||
|
||||
A beta release of the new Container Game Object arrives in this version. We've flagged it as beta because there are known issues in using Containers in Scenes that have multiple cameras or irregular camera viewports. However, in all other instances we've tested they are operating normally, so we felt it would be best to release them into this build to give developers a chance to get used to them. Using a Container will issue a single console warning as a reminder. We will remove this once they leave beta in a future release. In the meantime they are fully documented and you can find numerous examples in the Phaser 3 Examples repo too.
|
||||
|
||||
* A new property was added to Matter.World, `correction` which is used in the Engine.update call and allows you to adjust the time being passed to the simulation. The default value is 1 to remain consistent with previous releases.
|
||||
* Matter Physics now has a new config property `getDelta` which allows you to specify your own function to calculate the delta value given to the Matter Engine when it updates.
|
||||
* Matter Physics has two new methods: `set60Hz` and `set30Hz` which will set an Engine update rate of 60Hz and 30Hz respectively. 60Hz being the default.
|
||||
|
@ -47,6 +109,7 @@
|
|||
* TransformMatrix.destroy is a new method that will clear out the array and object used by a Matrix internally.
|
||||
* BaseSound, and by extension WebAudioSound and HTMLAudioSound, will now emit a `destroy` event when they are destroyed (thanks @rexrainbow)
|
||||
* A new property was added to the Scene config: `mapAdd` which is used to extend the default injection map of a scene instead of overwriting it (thanks @sebashwa)
|
||||
* GetBounds `getTopLeft`, `getTopRight`, `getBottomLeft` and `getBottomRight` all have a new optional argument `includeParent` which will factor in all ancestor transforms to the returned point.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
@ -166,9 +229,6 @@ My thanks to the following for helping with the Phaser 3 Examples, Docs and Type
|
|||
|
||||
@gabegordon @melissaelopez @samid737 @nbs @tgrajewski @pagesrichie @hexus @mbrickn @erd0s @icbat @Matthew-Herman @ampled @mkimmet @PaNaVTEC
|
||||
|
||||
|
||||
|
||||
|
||||
## Version 3.3.0 - Tetsuo - 22nd March 2018
|
||||
|
||||
A special mention must go to @orblazer for their outstanding assistance in helping to complete the JSDoc data-types, callbacks and type defs across the API.
|
||||
|
|
274
README.md
274
README.md
|
@ -24,9 +24,9 @@ Grab the source and join the fun!
|
|||
|
||||
<div align="center"><img src="https://phaser.io/images/github/news.jpg"></div>
|
||||
|
||||
> 22nd March 2018
|
||||
> 12th April 2018
|
||||
|
||||
**Updated:** I'm pleased to report that development continues at a rapid pace. We're slashing through issues and feature requests as quickly as possible, as well as improving the JSDocs across the entire API. 3.3.0 was released today and we'll launch directly into the next version. Check out the [Change Log](#changelog) for more details.
|
||||
**Updated:** I'm pleased to announce the immediate release of Phaser 3.4. This is a huge update, bringing lots of fixes and enhancements from the core team and wider community. We've also updated the TypeScript defs to 3.4. As always, please check out the [Change Log](#changelog) for comprehensive details about what this version contains.
|
||||
|
||||
After 1.5 years in the making, tens of thousands of lines of code, hundreds of examples and countless hours of relentless work: Phaser 3 is finally out. It has been a real labor of love and then some!
|
||||
|
||||
|
@ -96,13 +96,13 @@ npm install phaser
|
|||
[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>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.4.0/dist/phaser.js"></script>
|
||||
```
|
||||
|
||||
or the minified version:
|
||||
|
||||
```html
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.3.0/dist/phaser.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/phaser@3.4.0/dist/phaser.min.js"></script>
|
||||
```
|
||||
|
||||
### API Documentation
|
||||
|
@ -260,118 +260,174 @@ You can then run `webpack` to create a development build in the `build` folder w
|
|||

|
||||
<a name="changelog"></a>
|
||||
|
||||
## Version 3.3.0 - Tetsuo - 22nd March 2018
|
||||
|
||||
A special mention must go to @orblazer for their outstanding assistance in helping to complete the JSDoc data-types, callbacks and type defs across the API.
|
||||
## Version 3.4.0 - Miyako - 12th April 2018
|
||||
|
||||
### New Features
|
||||
|
||||
* TextStyle has two new properties: `baselineX` and `baselineY` which allow you to customize the 'magic' value used in calculating the text metrics.
|
||||
* Game.Config.preserveDrawingBuffer is now passed to the WebGL Renderer (default `false`).
|
||||
* Game.Config.failIfMajorPerformanceCaveat is now passed to the WebGL Renderer (default `false`).
|
||||
* Game.Config.powerPreference is now passed to the WebGL Renderer (default `default`).
|
||||
* Game.Config.antialias is now passed to the WebGL Renderer as the antialias context property (default `true`).
|
||||
* Game.Config.pixelArt is now only used by the WebGL Renderer when creating new textures.
|
||||
* Game.Config.premultipliedAlpha is now passed to the WebGL Renderer as the premultipliedAlpha context property (default `true`).
|
||||
* You can now specify all of the renderer config options within a `render` object in the config. If no `render` object is found, it will scan the config object directly for the properties.
|
||||
* Group.create has a new optional argument: `active` which will set the active state of the child being created (thanks @samme)
|
||||
* Group.create has a new optional argument: `active` which will set the active state of the child being created (thanks @samme)
|
||||
* Group.createMultiple now allows you to include the `active` property in the config object (thanks @samme)
|
||||
* TileSprite has a new method: `setTilePosition` which allows you to set the tile position in a chained called (thanks @samme)
|
||||
* Added the new Action - WrapInRectangle. This will wrap each items coordinates within a rectangles area (thanks @samme)
|
||||
* Arcade Physics has the new methods `wrap`, `wrapArray` and `wrapObject` which allow you to wrap physics bodies around the world bounds (thanks @samme)
|
||||
* The Tweens Timeline has a new method: `makeActive` which delegates control to the Tween Manager (thanks @allanbreyes)
|
||||
* Actions.GetLast will return the last element in the items array matching the conditions.
|
||||
* Actions.PropertyValueInc is a new action that will increment any property of an array of objects by the given amount, using an optional step value, index and iteration direction. Most Actions have been updated to use this internally.
|
||||
* Actions.PropertyValueSet is a new action that will set any property of an array of objects to the given value, using an optional step value, index and iteration direction. Most Actions have been updated to use this internally.
|
||||
* Camera.shake now has an optional `callback` argument that is invoked when the effect completes (thanks @pixelscripter)
|
||||
* Camera.fade now has an optional `callback` argument that is invoked when the effect completes (thanks @pixelscripter)
|
||||
* Camera.flash now has an optional `callback` argument that is invoked when the effect completes (thanks @pixelscripter)
|
||||
* Camera.fadeIn is a new method that will fade the camera in from a given color (black by default) and then optionally invoke a callback. This is the same as using Camera.flash but with an easier to grok method name. Fix #3412 (thanks @Jerenaux)
|
||||
* Camera.fadeOut is a new method that will fade the camera out to a given color (black by default) and then optionally invoke a callback. This is the same as using Camera.fade but with an easier to grok method name. Fix #3412 (thanks @Jerenaux)
|
||||
* Groups will now listen for a `destroy` event from any Game Object added to them, and if received will automatically remove that GameObject from the Group. Fix #3418 (thanks @hadikcz)
|
||||
* MatterGameObject is a new function, available via the Matter Factory in `this.matter.add.gameObject`, that will inject a Matter JS Body into any Game Object, such as a Text or TileSprite object.
|
||||
* Matter.SetBody and SetExistingBody will now set the origin of the Game Object to be the Matter JS sprite.xOffset and yOffset values, which will auto-center the Game Object to the origin of the body, regardless of shape.
|
||||
* SoundManager.setRate is a chainable method to allow you to set the global playback rate of all sounds in the SoundManager.
|
||||
* SoundManager.setDetune is a chainable method to allow you to set the global detuning of all sounds in the SoundManager.
|
||||
* SoundManager.setMute is a chainable method to allow you to set the global mute state of the SoundManager.
|
||||
* SoundManager.setVolume is a chainable method to allow you to set the global volume of the SoundManager.
|
||||
* BaseSound.setRate is a chainable method to allow you to set the playback rate of the BaseSound.
|
||||
* BaseSound.setDetune is a chainable method to allow you to set the detuning value of the BaseSound.
|
||||
A beta release of the new Container Game Object arrives in this version. We've flagged it as beta because there are known issues in using Containers in Scenes that have multiple cameras or irregular camera viewports. However, in all other instances we've tested they are operating normally, so we felt it would be best to release them into this build to give developers a chance to get used to them. Using a Container will issue a single console warning as a reminder. We will remove this once they leave beta in a future release. In the meantime they are fully documented and you can find numerous examples in the Phaser 3 Examples repo too.
|
||||
|
||||
* A new property was added to Matter.World, `correction` which is used in the Engine.update call and allows you to adjust the time being passed to the simulation. The default value is 1 to remain consistent with previous releases.
|
||||
* Matter Physics now has a new config property `getDelta` which allows you to specify your own function to calculate the delta value given to the Matter Engine when it updates.
|
||||
* Matter Physics has two new methods: `set60Hz` and `set30Hz` which will set an Engine update rate of 60Hz and 30Hz respectively. 60Hz being the default.
|
||||
* Matter Physics has a new config and run-time property `autoUpdate`, which defaults to `true`. When enabled the Matter Engine will update in sync with the game step (set by Request Animation Frame). The delta value given to Matter is now controlled by the `getDelta` function.
|
||||
* Matter Physics has a new method `step` which manually advances the physics simulation by one iteration, using whatever delta and correction values you pass in to it. When used in combination with `autoUpdate=false` you can now explicitly control the update frequency of the physics simulation and unbind it from the game step.
|
||||
* 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)
|
||||
* Group.destroy has a new optional argument `destroyChildren` which will automatically call `destroy` on all children of a Group if set to true (the default is false, hence it doesn't change the public API). Fix #3246 (thanks @DouglasLapsley)
|
||||
* WebAudioSound.setMute is a chainable way to mute a single Sound instance.
|
||||
* WebAudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
|
||||
* WebAudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
|
||||
* WebAudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
|
||||
* HTML5AudioSound.setMute is a chainable way to mute a single Sound instance.
|
||||
* 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)
|
||||
* 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.
|
||||
* ScenePlugin.restart allows you to restart the current Scene. It's the same result as calling `ScenePlugin.start` without any arguments, but is more clear.
|
||||
* Utils.Array.Add allows you to add one or more items safely to an array, with optional limits and callbacks.
|
||||
* Utils.Array.AddAt allows you to add one or more items safely to an array at a specified position, with optional limits and callbacks.
|
||||
* Utils.Array.BringToTop allows you to bring an array element to the top of the array.
|
||||
* Utils.Array.CountAllMatching will scan an array and count all elements with properties matching the given value.
|
||||
* Utils.Array.Each will pass each element of an array to a given callback, with optional arguments.
|
||||
* Utils.Array.EachInRange will pass each element of an array in a given range to a callback, with optional arguments.
|
||||
* Utils.Array.GetAll will return all elements from an array, with optional property and value comparisons.
|
||||
* Utils.Array.GetFirst will return the first element in an array, with optional property and value comparisons.
|
||||
* Utils.Array.GetRandomElement has been renamed to GetRandom and will return a random element from an array.
|
||||
* Utils.Array.MoveDown will move the given array element down one position in the array.
|
||||
* Utils.Array.MoveTo will move the given array element to the given position in the array.
|
||||
* Utils.Array.MoveUp will move the given array element up one position in the array.
|
||||
* Utils.Array.Remove will remove the given element or array of elements from the array, with an optional callback.
|
||||
* Utils.Array.RemoveAt will remove the element from the given position in the array, with an optional callback.
|
||||
* Utils.Array.RemoveBetween will remove the elements between the given range in the array, with an optional callback.
|
||||
* Utils.Array.Replace will replace an existing element in an array with a new one.
|
||||
* Utils.Array.SendToBack allows you to send an array element to the bottom of the array.
|
||||
* Utils.Array.SetAll will set a property on all elements of an array to the given value, with optional range limits.
|
||||
* Utils.Array.Swap will swap the position of two elements in an array.
|
||||
* TransformMatrix.destroy is a new method that will clear out the array and object used by a Matrix internally.
|
||||
* BaseSound, and by extension WebAudioSound and HTMLAudioSound, will now emit a `destroy` event when they are destroyed (thanks @rexrainbow)
|
||||
* A new property was added to the Scene config: `mapAdd` which is used to extend the default injection map of a scene instead of overwriting it (thanks @sebashwa)
|
||||
* GetBounds `getTopLeft`, `getTopRight`, `getBottomLeft` and `getBottomRight` all have a new optional argument `includeParent` which will factor in all ancestor transforms to the returned point.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed the Debug draw of a scaled circle body in Arcade Physics (thanks @pixelpicosean)
|
||||
* Fixed bug in `DataManager.merge` where it would copy the object reference instead of its value (thanks @rexrainbow)
|
||||
* The SceneManager no longer copies over the `shutdown` and `destroy` callbacks in createSceneFromObject, as these are not called automatically and should be invoked via the Scene events (thanks @samme)
|
||||
* The default Gamepad Button threshold has been changed from 0 to 1. Previously the value of 0 was making all gamepad buttons appear as if they were always pressed down (thanks @jmcriat)
|
||||
* InputManager.hitTest will now factor the game resolution into account, stopping the tests from being offset if resolution didn't equal 1 (thanks @sftsk)
|
||||
* CameraManager.getCamera now returns the Camera based on its name (thanks @bigbozo)
|
||||
* Fixed Tile Culling for zoomed Cameras. When a Camera was zoomed the tiles would be aggressively culled as the dimensions didn't factor in the zoom level (thanks @bigbozo)
|
||||
* When calling ScenePlugin.start any additional data passed to the method would be lost if the scene wasn't in an active running state (thanks @stuff)
|
||||
* When calling Timeline.resetTweens, while the tweens are pending removal or completed, it would throw a TypeError about the undefined `makeActive` (thanks @allanbreyes)
|
||||
* The WebGL Context would set `antialias` to `undefined` as it wasn't set in the Game Config. Fix #3386 (thanks @samme)
|
||||
* The TweenManager will now check the state of a tween before playing it. If not in a pending state it will be skipped. This allows you to stop a tween immediately after creating it and not have it play through once anyway. Fix #3405 (thanks @Twilrom)
|
||||
* The InputPlugin.processOverOutEvents method wasn't correctly working out the total of the number of objects interacted with, which caused input events to be disabled in Scenes further down the scene list if something was being dragged in an upper scene. Fix #3399 (thanks @Jerenaux)
|
||||
* The InputPlugin.processDragEvents wasn't always returning an integer.
|
||||
* LoaderPlugin.progress and the corresponding event now factor in both the list size and the inflight size when calculating the percentage complete. Fix #3384 (thanks @vinerz @rblopes @samme)
|
||||
* Phaser.Utils.Array.Matrix.RotateLeft actually rotated to the right (thanks @Tomas2h)
|
||||
* Phaser.Utils.Array.Matrix.RotateRight actually rotated to the left (thanks @Tomas2h)
|
||||
* When deleting a Scene from the SceneManager it would set the key in the scenes has to `undefined`, preventing you from registering a new Scene with the same key. It's now properly removed from the hash(thanks @macbury)
|
||||
* Graphics.alpha was being ignored in the WebGL renderer and is now applied properly to strokes and fills. Fix #3426 (thanks @Ziao)
|
||||
* The font is now synced to the context in Text before running a word wrap, this ensures the wrapping result between updating the text and getting the wrapped text is the same. Fix #3389 (thanks @rexrainbow)
|
||||
* Added the ComputedSize component to the Text Game Object, which allows Text.getBounds, and related methods, to work again instead of returning NaN.
|
||||
* Group.remove now calls the `removeCallback` and passes it the child that was removed (thanks @orblazer)
|
||||
* In the WebGL Render Texture the tint of the texture was always set to 0xffffff and therefore the alpha values were ignored. The tint is now calculated using the alpha value. Fix #3385 (thanks @ger1995)
|
||||
* The RenderTexture now uses the ComputedSize component instead of Size (which requires a frame), allowing calls to getBounds to work. Fix #3451 (thanks @kuoruan)
|
||||
* 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.
|
||||
* 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` and `create` methods and stored in the Scene Settings `data` property. Fix #3363 (thanks @pixelhijack)
|
||||
* Tween.restart handles removed tweens properly and reads them back into the active queue for the TweenManager (thanks @wtravO)
|
||||
* Tween.resume will now call `Tween.play` on a tween that was paused due to its config object, not as a result of having its paused method called. Fix #3452 (thanks @jazen)
|
||||
* LoaderPlugin.isReady referenced a constant that no longer exists. Fix #3503 (thanks @Twilrom)
|
||||
* Tween Timeline.destroy was trying to call `destroy` on Tweens instead of `stop` (thanks @Antriel)
|
||||
* Calling `setOffset` on a Static Arcade Physics Body would break because the method was missing. It has been added and now functions as expected. Fix #3465 (thanks @josephjaniga and @DouglasLapsley)
|
||||
* Calling Impact.World.remove(body) during a Body.updateCallback would cause the internal loop to crash when trying to access a now missing body. Two extra checks are in place to avoid this (thanks @iamDecode)
|
||||
* If `setInteractive` is called on a Game Object that fails to set a hit area, it will no longer try to assign `dropZone` to an undefined `input` property.
|
||||
* The Matter SetBody Component will no longer try to call `setOrigin` unless the Game Object has the origin component (which not all do, like Graphics and Container)
|
||||
* Matter Image and Matter Sprite didn't define a `destroy` method, causing an error when trying to destroy the parent Game Object. Fix #3516 (thanks @RollinSafary)
|
||||
|
||||
### Updates
|
||||
|
||||
* The Text testString has changed from `|MÉqgy` to `|MÉqgy`.
|
||||
* The WebGLRenderer width and height values are now floored when multiplied by the resolution.
|
||||
* The WebGL Context now sets `premultipliedAlpha` to `true` by default, this prevents the WebGL context from rendering as plain white under certain versions of macOS Safari.
|
||||
* The Phaser.Display.Align constants are now exposed on the namespace. Fix #3387 (thanks @samme)
|
||||
* The Phaser.Loader constants are now exposed on the namespace. Fix #3387 (thanks @samme)
|
||||
* The Phaser.Physics.Arcade constants are now exposed on the namespace. Fix #3387 (thanks @samme)
|
||||
* The Phaser.Scene constants are now exposed on the namespace. Fix #3387 (thanks @samme)
|
||||
* The Phaser.Tweens constants are now exposed on the namespace. Fix #3387 (thanks @samme)
|
||||
* The Array Matrix utils are now exposed and available via `Phaser.Utils.Array.Matrix`.
|
||||
* Actions.Angle has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.IncAlpha has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.IncX has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.IncY has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.IncXY has 4 new arguments: `stepX`, `stepY`, `index` and `direction`.
|
||||
* Actions.Rotate has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.ScaleX has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.ScaleXY has 4 new arguments: `stepX`, `stepY`, `index` and `direction`.
|
||||
* Actions.ScaleY has 3 new arguments: `step`, `index` and `direction`.
|
||||
* Actions.SetAlpha has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetBlendMode has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetDepth has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetOrigin has 4 new arguments: `stepX`, `stepY`, `index` and `direction`.
|
||||
* Actions.SetRotation has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetScale has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetScaleX has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetScaleY has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetVisible has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetX has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetXY has 2 new arguments: `index` and `direction`.
|
||||
* Actions.SetY has 2 new arguments: `index` and `direction`.
|
||||
* Line.getPointA now returns a Vector2 instead of an untyped object. It also now has an optional argument that allows you to pass a vec2 in to be populated, rather than creating a new one.
|
||||
* Line.getPointB now returns a Vector2 instead of an untyped object. It also now has an optional argument that allows you to pass a vec2 in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineD now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* The GameObject `destroy` event is now emitted at the start of the destroy process, before things like the body or input managers have been removed, so you're able to use the event handler to extract any information you require from the GameObject before it's actually disposed of. Previously, the event was dispatched at the very end of the process.
|
||||
* Phaser 3 is now built with Webpack v4.1.1 and all related packages have been updated (thanks @orblazer)
|
||||
* On WebGL the currentScissor is now updated when the renderer `resize` method is called (thanks @jmcriat)
|
||||
* PathFollower.start has been renamed to `startFollow` to avoid conflicting with the Animation component.
|
||||
* PathFollower.pause has been renamed to `pauseFollow` to avoid conflicting with the Animation component.
|
||||
* PathFollower.resume has been renamed to `resumeFollow` to avoid conflicting with the Animation component.
|
||||
* PathFollower.stop has been renamed to `stopFollow` to avoid conflicting with the Animation component.
|
||||
* BaseSound.setRate has been renamed to `calculateRate` to avoid confusion over the setting of the sounds rate.
|
||||
* The RTree library (rbush) used by Phaser 3 suffered from violating CSP policies by dynamically creating Functions at run-time in an eval-like manner. These are now defined via generators. Fix #3441 (thanks @jamierocks @Colbydude @jdotrjs)
|
||||
* BaseSound has had its `rate` and `detune` properties removed as they are always set in the overriding class.
|
||||
* BaseSound `setRate` and `setDetune` from the 3.4.0 release have moved to the WebAudioSound and HTML5AudioSound classes respectively, as they each handle the values differently.
|
||||
* The file `InteractiveObject.js` has been renamed to `CreateInteractiveObject.js` to more accurately reflect what it does and to avoid type errors in the docs.
|
||||
* Renamed the Camera Controls module exports for `Fixed` to `FixedKeyControl` and `Smoothed` to `SmoothedKeyControl` to match the class names. Fix #3463 (thanks @seivan)
|
||||
* 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`.
|
||||
* When using the `extend` property of a Scene config object it will now block overwriting the Scene `sys` property.
|
||||
* When using the `extend` property of a Scene config object, if you define a property called `data` that has an object set, it will populate the Scenes Data Manager with those values.
|
||||
* SceneManager._processing has been renamed to `isProcessing` which is now a boolean, not an integer. It's also now public and read-only.
|
||||
* SceneManager.isBooted is a new boolean read-only property that lets you know if the Scene Manager has performed its initial boot sequence.
|
||||
* TransformMatrix has the following new getter and setters: `a`, `b`, `c`, `d`, `tx` and `ty`. It also has the following new getters: `scaleX`, `scaleY` and `rotation`.
|
||||
* List.getByKey has been removed. Use `List.getFirst` instead which offers the exact same functionality.
|
||||
* List.sortIndexHandler has been removed because it's no longer required.
|
||||
* List.sort no longer takes an array as its argument, instead it only sorts the List contents by the defined property.
|
||||
* List.addMultiple has been removed. Used `List.add` instead which offers the exact same functionality.
|
||||
* List is now internally using all of the new Utils.Array functions.
|
||||
* Rectangle.Union will now cache all vars internally so you can use one of the input rectangles as the output rectangle without corrupting it.
|
||||
* When shutting down a Matter World it will now call MatterEvents.off, clearing all events, and also `removeAllListeners` for any local events.
|
||||
* Removed InputPlugin.sortInteractiveObjects because the method isn't used anywhere internally.
|
||||
|
||||
### 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
|
||||
|
||||
Please see the complete [Change Log](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md) for previous releases.
|
||||
|
||||
|
@ -404,8 +460,8 @@ All rights reserved.
|
|||
|
||||
"Above all, video games are meant to be just one thing: fun. Fun for everyone." - Satoru Iwata
|
||||
|
||||
[get-js]: https://github.com/photonstorm/phaser/releases/download/v3.3.0/phaser.js
|
||||
[get-minjs]: https://github.com/photonstorm/phaser/releases/download/v3.3.0/phaser.min.js
|
||||
[get-js]: https://github.com/photonstorm/phaser/releases/download/v3.4.0/phaser.js
|
||||
[get-minjs]: https://github.com/photonstorm/phaser/releases/download/v3.4.0/phaser.min.js
|
||||
[clone-http]: https://github.com/photonstorm/phaser.git
|
||||
[clone-ssh]: git@github.com:photonstorm/phaser.git
|
||||
[clone-ghwin]: github-windows://openRepo/https://github.com/photonstorm/phaser
|
||||
|
|
|
@ -6,8 +6,31 @@ let sourceMap = './build/phaser.js.map';
|
|||
let dest = '../phaser3-examples/public/build/dev.js';
|
||||
let destMap = '../phaser3-examples/public/build/phaser.js.map';
|
||||
|
||||
let sourceCore = './build/phaser-core.js';
|
||||
let sourceMapCore = './build/phaser-core.js.map';
|
||||
let destCore = '../phaser3-examples/public/build/phaser-core.js';
|
||||
let destMapCore = '../phaser3-examples/public/build/phaser-core.js.map';
|
||||
|
||||
if (fs.existsSync(dest))
|
||||
{
|
||||
fs.copy(sourceMapCore, destMapCore, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fs.copy(sourceCore, destCore, function (err) {
|
||||
|
||||
if (err)
|
||||
{
|
||||
return console.error(err);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fs.copy(sourceMap, destMap, function (err) {
|
||||
|
||||
if (err)
|
||||
|
|
27366
dist/phaser-arcade-physics.js
vendored
27366
dist/phaser-arcade-physics.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/phaser-arcade-physics.min.js
vendored
2
dist/phaser-arcade-physics.min.js
vendored
File diff suppressed because one or more lines are too long
29877
dist/phaser.js
vendored
29877
dist/phaser.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/phaser.min.js
vendored
2
dist/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "phaser",
|
||||
"version": "3.4.0",
|
||||
"release": "Tetsuo",
|
||||
"version": "3.5.0",
|
||||
"release": "Miyako",
|
||||
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
|
||||
"author": "Richard Davey <rich@photonstorm.com> (http://www.photonstorm.com)",
|
||||
"logo": "https://raw.github.com/photonstorm/phaser/master/phaser-logo-small.png",
|
||||
|
|
|
@ -10,7 +10,7 @@ var GetFastValue = require('../utils/object/GetFastValue');
|
|||
var NOOP = require('../utils/NOOP');
|
||||
var Zone = require('../gameobjects/zone/Zone');
|
||||
|
||||
var tempZone = new Zone({ sys: { queueDepthSort: NOOP }}, 0, 0, 1, 1);
|
||||
var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1);
|
||||
|
||||
/**
|
||||
* @typedef {object} GridAlignConfig
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -66,11 +66,6 @@ var CameraManager = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The current Camera ID.
|
||||
*
|
||||
|
@ -100,17 +95,6 @@ var CameraManager = new Class({
|
|||
*/
|
||||
this.cameraPool = [];
|
||||
|
||||
if (scene.sys.settings.cameras)
|
||||
{
|
||||
// We have cameras to create
|
||||
this.fromJSON(scene.sys.settings.cameras);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make one
|
||||
this.add();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default Camera in the Camera Manager.
|
||||
*
|
||||
|
@ -118,7 +102,7 @@ var CameraManager = new Class({
|
|||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.main = this.cameras[0];
|
||||
this.main;
|
||||
|
||||
/**
|
||||
* This scale affects all cameras. It's used by Scale Manager.
|
||||
|
@ -127,23 +111,42 @@ var CameraManager = new Class({
|
|||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.baseScale = 1.0;
|
||||
this.baseScale = 1;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when the Camera Manager boots.
|
||||
* Starts the event listeners running.
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
var sys = this.systems;
|
||||
|
||||
if (sys.settings.cameras)
|
||||
{
|
||||
// We have cameras to create
|
||||
this.fromJSON(sys.settings.cameras);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make one
|
||||
this.add();
|
||||
}
|
||||
|
||||
this.main = this.cameras[0];
|
||||
|
||||
var eventEmitter = sys.events;
|
||||
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -444,23 +447,14 @@ var CameraManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
// TODO
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.main = undefined;
|
||||
|
||||
|
@ -476,7 +470,29 @@ var CameraManager = new Class({
|
|||
|
||||
this.cameras = [];
|
||||
this.cameraPool = [];
|
||||
this.scene = undefined;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
430
src/cameras/2d/effects/Fade.js
Normal file
430
src/cameras/2d/effects/Fade.js
Normal file
|
@ -0,0 +1,430 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Clamp = require('../../../math/Clamp');
|
||||
var Class = require('../../../utils/Class');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Camera Fade effect.
|
||||
*
|
||||
* This effect will fade the camera viewport to the given color, over the duration specified.
|
||||
*
|
||||
* Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do
|
||||
* not change.
|
||||
*
|
||||
* The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback,
|
||||
* which is invoked each frame for the duration of the effect, if required.
|
||||
*
|
||||
* @class Fade
|
||||
* @memberOf Phaser.Cameras.Scene2D.Effects
|
||||
* @constructor
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon.
|
||||
*/
|
||||
var Fade = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function Fade (camera)
|
||||
{
|
||||
/**
|
||||
* The Camera this effect belongs to.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#camera
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
/**
|
||||
* Is this effect actively running?
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#isRunning
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
/**
|
||||
* Has this effect finished running?
|
||||
*
|
||||
* This is different from `isRunning` because it remains set to `true` when the effect is over,
|
||||
* until the effect is either reset or started again.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#isComplete
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.isComplete = false;
|
||||
|
||||
/**
|
||||
* The direction of the fade.
|
||||
* `true` = fade out (transparent to color), `false` = fade in (color to transparent)
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#direction
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.direction = true;
|
||||
|
||||
/**
|
||||
* The duration of the effect, in milliseconds.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#duration
|
||||
* @type {integer}
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* The value of the red color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#red
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.red = 0;
|
||||
|
||||
/**
|
||||
* The value of the green color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#green
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.green = 0;
|
||||
|
||||
/**
|
||||
* The value of the blue color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#blue
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.blue = 0;
|
||||
|
||||
/**
|
||||
* The value of the alpha channel used during the fade effect.
|
||||
* A value between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#alpha
|
||||
* @type {float}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.alpha = 0;
|
||||
|
||||
/**
|
||||
* If this effect is running this holds the current percentage of the progress, a value between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#progress
|
||||
* @type {float}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
/**
|
||||
* Effect elapsed timer.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#_elapsed
|
||||
* @type {number}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._elapsed = 0;
|
||||
|
||||
/**
|
||||
* @callback CameraFadeCallback
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
|
||||
* @param {float} progress - The progress of the effect. A value between 0 and 1.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This callback is invoked every frame for the duration of the effect.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdate
|
||||
* @type {?CameraFadeCallback}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdate;
|
||||
|
||||
/**
|
||||
* On Complete callback scope.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdateScope
|
||||
* @type {any}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdateScope;
|
||||
},
|
||||
|
||||
/**
|
||||
* This event is fired when the fade in effect begins to run on a camera.
|
||||
*
|
||||
* @event CameraFadeInStartEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance.
|
||||
* @param {integer} duration - The duration of the effect.
|
||||
* @param {integer} red - The red color channel value.
|
||||
* @param {integer} green - The green color channel value.
|
||||
* @param {integer} blue - The blue color channel value.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is fired when the fade out effect begins to run on a camera.
|
||||
*
|
||||
* @event CameraFadeOutStartEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance.
|
||||
* @param {integer} duration - The duration of the effect.
|
||||
* @param {integer} red - The red color channel value.
|
||||
* @param {integer} green - The green color channel value.
|
||||
* @param {integer} blue - The blue color channel value.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is fired when the fade in effect completes.
|
||||
*
|
||||
* @event CameraFadeInCompleteEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is fired when the fade out effect completes.
|
||||
*
|
||||
* @event CameraFadeOutCompleteEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fades the Camera to or from the given color over the duration specified.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#start
|
||||
* @fires CameraFadeInStartEvent
|
||||
* @fires CameraFadeInCompleteEvent
|
||||
* @fires CameraFadeOutStartEvent
|
||||
* @fires CameraFadeOutCompleteEvent
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {boolean} [direction=true] - The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent)
|
||||
* @param {integer} [duration=1000] - The duration of the effect in milliseconds.
|
||||
* @param {integer} [red=0] - The amount to fade the red channel towards. A value between 0 and 255.
|
||||
* @param {integer} [green=0] - The amount to fade the green channel towards. A value between 0 and 255.
|
||||
* @param {integer} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255.
|
||||
* @param {boolean} [force=false] - Force the effect to start immediately, even if already running.
|
||||
* @param {CameraFadeCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
|
||||
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
|
||||
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started.
|
||||
*/
|
||||
start: function (direction, duration, red, green, blue, force, callback, context)
|
||||
{
|
||||
if (direction === undefined) { direction = true; }
|
||||
if (duration === undefined) { duration = 1000; }
|
||||
if (red === undefined) { red = 0; }
|
||||
if (green === undefined) { green = 0; }
|
||||
if (blue === undefined) { blue = 0; }
|
||||
if (force === undefined) { force = false; }
|
||||
if (callback === undefined) { callback = null; }
|
||||
if (context === undefined) { context = this.camera.scene; }
|
||||
|
||||
if (!force && this.isRunning)
|
||||
{
|
||||
return this.camera;
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
this.isComplete = false;
|
||||
this.duration = duration;
|
||||
this.direction = direction;
|
||||
this.progress = 0;
|
||||
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = (direction) ? Number.MIN_VALUE : 1;
|
||||
|
||||
this._elapsed = 0;
|
||||
|
||||
this._onUpdate = callback;
|
||||
this._onUpdateScope = context;
|
||||
|
||||
var eventName = (direction) ? 'camerafadeoutstart' : 'camerafadeinstart';
|
||||
|
||||
this.camera.emit(eventName, this.camera, this, duration, red, green, blue);
|
||||
|
||||
return this.camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* The main update loop for this effect. Called automatically by the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#update
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
|
||||
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
|
||||
*/
|
||||
update: function (time, delta)
|
||||
{
|
||||
if (!this.isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._elapsed += delta;
|
||||
|
||||
this.progress = Clamp(this._elapsed / this.duration, 0, 1);
|
||||
|
||||
if (this._onUpdate)
|
||||
{
|
||||
this._onUpdate.call(this._onUpdateScope, this.camera, this.progress);
|
||||
}
|
||||
|
||||
if (this._elapsed < this.duration)
|
||||
{
|
||||
this.alpha = (this.direction) ? this.progress : 1 - this.progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.effectComplete();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally by the Canvas Renderer.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderCanvas
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {CanvasRenderingContext2D} ctx - The Canvas context to render to.
|
||||
*
|
||||
* @return {boolean} `true` if the effect drew to the renderer, otherwise `false`.
|
||||
*/
|
||||
postRenderCanvas: function (ctx)
|
||||
{
|
||||
if (!this.isRunning && !this.isComplete)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var camera = this.camera;
|
||||
|
||||
ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')';
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally by the WebGL Renderer.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGL.WebGLPipeline.FlatTintPipeline} pipeline - The WebGL Pipeline to render to.
|
||||
* @param {function} getTintFunction - A function that will return the gl safe tint colors.
|
||||
*
|
||||
* @return {boolean} `true` if the effect drew to the renderer, otherwise `false`.
|
||||
*/
|
||||
postRenderWebGL: function (pipeline, getTintFunction)
|
||||
{
|
||||
if (!this.isRunning && !this.isComplete)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var camera = this.camera;
|
||||
var red = this.red / 255;
|
||||
var blue = this.blue / 255;
|
||||
var green = this.green / 255;
|
||||
|
||||
pipeline.batchFillRect(
|
||||
0, 0, 1, 1, 0,
|
||||
camera.x, camera.y, camera.width, camera.height,
|
||||
getTintFunction(red, green, blue, 1),
|
||||
this.alpha,
|
||||
1, 0, 0, 1, 0, 0,
|
||||
[ 1, 0, 0, 1, 0, 0 ]
|
||||
);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally when the effect completes.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#effectComplete
|
||||
* @since 3.5.0
|
||||
*/
|
||||
effectComplete: function ()
|
||||
{
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
|
||||
this.isRunning = false;
|
||||
this.isComplete = true;
|
||||
|
||||
var eventName = (this.direction) ? 'camerafadeoutcomplete' : 'camerafadeincomplete';
|
||||
|
||||
this.camera.emit(eventName, this.camera, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this camera effect.
|
||||
* If it was previously running, it stops instantly without calling its onComplete callback or emitting an event.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#reset
|
||||
* @since 3.5.0
|
||||
*/
|
||||
reset: function ()
|
||||
{
|
||||
this.isRunning = false;
|
||||
this.isComplete = false;
|
||||
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this effect, releasing it from the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Fade#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
|
||||
this.camera = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Fade;
|
373
src/cameras/2d/effects/Flash.js
Normal file
373
src/cameras/2d/effects/Flash.js
Normal file
|
@ -0,0 +1,373 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Clamp = require('../../../math/Clamp');
|
||||
var Class = require('../../../utils/Class');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Camera Flash effect.
|
||||
*
|
||||
* This effect will flash the camera viewport to the given color, over the duration specified.
|
||||
*
|
||||
* Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do
|
||||
* not change.
|
||||
*
|
||||
* The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback,
|
||||
* which is invoked each frame for the duration of the effect, if required.
|
||||
*
|
||||
* @class Flash
|
||||
* @memberOf Phaser.Cameras.Scene2D.Effects
|
||||
* @constructor
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon.
|
||||
*/
|
||||
var Flash = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function Flash (camera)
|
||||
{
|
||||
/**
|
||||
* The Camera this effect belongs to.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#camera
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
/**
|
||||
* Is this effect actively running?
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#isRunning
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
/**
|
||||
* The duration of the effect, in milliseconds.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#duration
|
||||
* @type {integer}
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* The value of the red color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#red
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.red = 0;
|
||||
|
||||
/**
|
||||
* The value of the green color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#green
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.green = 0;
|
||||
|
||||
/**
|
||||
* The value of the blue color channel the camera will use for the fade effect.
|
||||
* A value between 0 and 255.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#blue
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.blue = 0;
|
||||
|
||||
/**
|
||||
* The value of the alpha channel used during the fade effect.
|
||||
* A value between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#alpha
|
||||
* @type {float}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.alpha = 0;
|
||||
|
||||
/**
|
||||
* If this effect is running this holds the current percentage of the progress, a value between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#progress
|
||||
* @type {float}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
/**
|
||||
* Effect elapsed timer.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#_elapsed
|
||||
* @type {number}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._elapsed = 0;
|
||||
|
||||
/**
|
||||
* @callback CameraFlashCallback
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
|
||||
* @param {float} progress - The progress of the effect. A value between 0 and 1.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This callback is invoked every frame for the duration of the effect.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdate
|
||||
* @type {?CameraFlashCallback}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdate;
|
||||
|
||||
/**
|
||||
* On Complete callback scope.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdateScope
|
||||
* @type {any}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdateScope;
|
||||
},
|
||||
|
||||
/**
|
||||
* This event is fired when the flash effect begins to run on a camera.
|
||||
*
|
||||
* @event CameraFlashStartEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance.
|
||||
* @param {integer} duration - The duration of the effect.
|
||||
* @param {integer} red - The red color channel value.
|
||||
* @param {integer} green - The green color channel value.
|
||||
* @param {integer} blue - The blue color channel value.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is fired when the flash effect completes.
|
||||
*
|
||||
* @event CameraFlashCompleteEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Flashes the Camera to or from the given color over the duration specified.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#start
|
||||
* @fires CameraFlashStartEvent
|
||||
* @fires CameraFlashCompleteEvent
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {integer} [duration=250] - The duration of the effect in milliseconds.
|
||||
* @param {integer} [red=255] - The amount to fade the red channel towards. A value between 0 and 255.
|
||||
* @param {integer} [green=255] - The amount to fade the green channel towards. A value between 0 and 255.
|
||||
* @param {integer} [blue=255] - The amount to fade the blue channel towards. A value between 0 and 255.
|
||||
* @param {boolean} [force=false] - Force the effect to start immediately, even if already running.
|
||||
* @param {CameraFlashCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
|
||||
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
|
||||
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started.
|
||||
*/
|
||||
start: function (duration, red, green, blue, force, callback, context)
|
||||
{
|
||||
if (duration === undefined) { duration = 250; }
|
||||
if (red === undefined) { red = 255; }
|
||||
if (green === undefined) { green = 255; }
|
||||
if (blue === undefined) { blue = 255; }
|
||||
if (force === undefined) { force = false; }
|
||||
if (callback === undefined) { callback = null; }
|
||||
if (context === undefined) { context = this.camera.scene; }
|
||||
|
||||
if (!force && this.isRunning)
|
||||
{
|
||||
return this.camera;
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
this.duration = duration;
|
||||
this.progress = 0;
|
||||
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
this.alpha = 1;
|
||||
|
||||
this._elapsed = 0;
|
||||
|
||||
this._onUpdate = callback;
|
||||
this._onUpdateScope = context;
|
||||
|
||||
this.camera.emit('cameraflashstart', this.camera, this, duration, red, green, blue);
|
||||
|
||||
return this.camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* The main update loop for this effect. Called automatically by the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#update
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
|
||||
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
|
||||
*/
|
||||
update: function (time, delta)
|
||||
{
|
||||
if (!this.isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._elapsed += delta;
|
||||
|
||||
this.progress = Clamp(this._elapsed / this.duration, 0, 1);
|
||||
|
||||
if (this._onUpdate)
|
||||
{
|
||||
this._onUpdate.call(this._onUpdateScope, this.camera, this.progress);
|
||||
}
|
||||
|
||||
if (this._elapsed < this.duration)
|
||||
{
|
||||
this.alpha = 1 - this.progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.effectComplete();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally by the Canvas Renderer.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderCanvas
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {CanvasRenderingContext2D} ctx - The Canvas context to render to.
|
||||
*
|
||||
* @return {boolean} `true` if the effect drew to the renderer, otherwise `false`.
|
||||
*/
|
||||
postRenderCanvas: function (ctx)
|
||||
{
|
||||
if (!this.isRunning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var camera = this.camera;
|
||||
|
||||
ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')';
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally by the WebGL Renderer.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGL.WebGLPipeline.FlatTintPipeline} pipeline - The WebGL Pipeline to render to.
|
||||
* @param {function} getTintFunction - A function that will return the gl safe tint colors.
|
||||
*
|
||||
* @return {boolean} `true` if the effect drew to the renderer, otherwise `false`.
|
||||
*/
|
||||
postRenderWebGL: function (pipeline, getTintFunction)
|
||||
{
|
||||
if (!this.isRunning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var camera = this.camera;
|
||||
var red = this.red / 255;
|
||||
var blue = this.blue / 255;
|
||||
var green = this.green / 255;
|
||||
|
||||
pipeline.batchFillRect(
|
||||
0, 0, 1, 1, 0,
|
||||
camera.x, camera.y, camera.width, camera.height,
|
||||
getTintFunction(red, green, blue, 1),
|
||||
this.alpha,
|
||||
1, 0, 0, 1, 0, 0,
|
||||
[ 1, 0, 0, 1, 0, 0 ]
|
||||
);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally when the effect completes.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#effectComplete
|
||||
* @since 3.5.0
|
||||
*/
|
||||
effectComplete: function ()
|
||||
{
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
|
||||
this.isRunning = false;
|
||||
|
||||
this.camera.emit('cameraflashcomplete', this.camera, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this camera effect.
|
||||
* If it was previously running, it stops instantly without calling its onComplete callback or emitting an event.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#reset
|
||||
* @since 3.5.0
|
||||
*/
|
||||
reset: function ()
|
||||
{
|
||||
this.isRunning = false;
|
||||
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this effect, releasing it from the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Flash#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
|
||||
this.camera = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Flash;
|
336
src/cameras/2d/effects/Shake.js
Normal file
336
src/cameras/2d/effects/Shake.js
Normal file
|
@ -0,0 +1,336 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Clamp = require('../../../math/Clamp');
|
||||
var Class = require('../../../utils/Class');
|
||||
var Vector2 = require('../../../math/Vector2');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Camera Shake effect.
|
||||
*
|
||||
* This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame.
|
||||
*
|
||||
* Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do
|
||||
* not change.
|
||||
*
|
||||
* The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback,
|
||||
* which is invoked each frame for the duration of the effect if required.
|
||||
*
|
||||
* @class Shake
|
||||
* @memberOf Phaser.Cameras.Scene2D.Effects
|
||||
* @constructor
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon.
|
||||
*/
|
||||
var Shake = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function Shake (camera)
|
||||
{
|
||||
/**
|
||||
* The Camera this effect belongs to.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#camera
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
/**
|
||||
* Is this effect actively running?
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#isRunning
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
/**
|
||||
* The duration of the effect, in milliseconds.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#duration
|
||||
* @type {integer}
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* The intensity of the effect. Use small float values. The default when the effect starts is 0.05.
|
||||
* This is a Vector2 object, allowing you to control the shake intensity independently across x and y.
|
||||
* You can modify this value while the effect is active to create more varied shake effects.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#intensity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.intensity = new Vector2();
|
||||
|
||||
/**
|
||||
* If this effect is running this holds the current percentage of the progress, a value between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#progress
|
||||
* @type {float}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
/**
|
||||
* Effect elapsed timer.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#_elapsed
|
||||
* @type {number}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._elapsed = 0;
|
||||
|
||||
/**
|
||||
* How much to offset the camera by horizontally.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetX
|
||||
* @type {number}
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._offsetX = 0;
|
||||
|
||||
/**
|
||||
* How much to offset the camera by vertically.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetY
|
||||
* @type {number}
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._offsetY = 0;
|
||||
|
||||
/**
|
||||
* @callback CameraShakeCallback
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
|
||||
* @param {float} progress - The progress of the effect. A value between 0 and 1.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This callback is invoked every frame for the duration of the effect.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdate
|
||||
* @type {?CameraShakeCallback}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdate;
|
||||
|
||||
/**
|
||||
* On Complete callback scope.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdateScope
|
||||
* @type {any}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdateScope;
|
||||
},
|
||||
|
||||
/**
|
||||
* This event is fired when the shake effect begins to run on a camera.
|
||||
*
|
||||
* @event CameraShakeStartEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance.
|
||||
* @param {integer} duration - The duration of the effect.
|
||||
* @param {float} intensity - The intensity of the effect.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is fired when the shake effect completes.
|
||||
*
|
||||
* @event CameraShakeCompleteEvent
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on.
|
||||
* @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shakes the Camera by the given intensity over the duration specified.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#start
|
||||
* @fires CameraShakeStartEvent
|
||||
* @fires CameraShakeCompleteEvent
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {integer} [duration=100] - The duration of the effect in milliseconds.
|
||||
* @param {number} [intensity=0.05] - The intensity of the shake.
|
||||
* @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running.
|
||||
* @param {CameraShakeCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
|
||||
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
|
||||
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started.
|
||||
*/
|
||||
start: function (duration, intensity, force, callback, context)
|
||||
{
|
||||
if (duration === undefined) { duration = 100; }
|
||||
if (intensity === undefined) { intensity = 0.05; }
|
||||
if (force === undefined) { force = false; }
|
||||
if (callback === undefined) { callback = null; }
|
||||
if (context === undefined) { context = this.camera.scene; }
|
||||
|
||||
if (!force && this.isRunning)
|
||||
{
|
||||
return this.camera;
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
this.duration = duration;
|
||||
this.progress = 0;
|
||||
|
||||
if (typeof intensity === 'number')
|
||||
{
|
||||
this.intensity.set(intensity);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.intensity.set(intensity.x, intensity.y);
|
||||
}
|
||||
|
||||
this._elapsed = 0;
|
||||
this._offsetX = 0;
|
||||
this._offsetY = 0;
|
||||
|
||||
this._onUpdate = callback;
|
||||
this._onUpdateScope = context;
|
||||
|
||||
this.camera.emit('camerashakestart', this.camera, this, duration, intensity);
|
||||
|
||||
return this.camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* The pre-render step for this effect. Called automatically by the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#preRender
|
||||
* @since 3.5.0
|
||||
*/
|
||||
preRender: function ()
|
||||
{
|
||||
if (this.isRunning)
|
||||
{
|
||||
this.camera.matrix.translate(this._offsetX, this._offsetY);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The main update loop for this effect. Called automatically by the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#update
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
|
||||
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
|
||||
*/
|
||||
update: function (time, delta)
|
||||
{
|
||||
if (!this.isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._elapsed += delta;
|
||||
|
||||
this.progress = Clamp(this._elapsed / this.duration, 0, 1);
|
||||
|
||||
if (this._onUpdate)
|
||||
{
|
||||
this._onUpdate.call(this._onUpdateScope, this.camera, this.progress);
|
||||
}
|
||||
|
||||
if (this._elapsed < this.duration)
|
||||
{
|
||||
var intensity = this.intensity;
|
||||
var width = this.camera.width;
|
||||
var height = this.camera.height;
|
||||
var zoom = this.camera.zoom;
|
||||
|
||||
this._offsetX = (Math.random() * intensity.x * width * 2 - intensity.x * width) * zoom;
|
||||
this._offsetY = (Math.random() * intensity.y * height * 2 - intensity.y * height) * zoom;
|
||||
|
||||
if (this.camera.roundPixels)
|
||||
{
|
||||
this._offsetX |= 0;
|
||||
this._offsetY |= 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.effectComplete();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally when the effect completes.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#effectComplete
|
||||
* @since 3.5.0
|
||||
*/
|
||||
effectComplete: function ()
|
||||
{
|
||||
this._offsetX = 0;
|
||||
this._offsetY = 0;
|
||||
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
|
||||
this.isRunning = false;
|
||||
|
||||
this.camera.emit('camerashakecomplete', this.camera, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this camera effect.
|
||||
* If it was previously running, it stops instantly without calling its onComplete callback or emitting an event.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#reset
|
||||
* @since 3.5.0
|
||||
*/
|
||||
reset: function ()
|
||||
{
|
||||
this.isRunning = false;
|
||||
|
||||
this._offsetX = 0;
|
||||
this._offsetY = 0;
|
||||
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this effect, releasing it from the Camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Effects.Shake#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
|
||||
this.camera = null;
|
||||
this.intensity = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Shake;
|
17
src/cameras/2d/effects/index.js
Normal file
17
src/cameras/2d/effects/index.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace Phaser.Cameras.Scene2D.Effects
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
Fade: require('./Fade'),
|
||||
Flash: require('./Flash'),
|
||||
Shake: require('./Shake')
|
||||
|
||||
};
|
|
@ -11,6 +11,7 @@
|
|||
module.exports = {
|
||||
|
||||
Camera: require('./Camera'),
|
||||
CameraManager: require('./CameraManager')
|
||||
CameraManager: require('./CameraManager'),
|
||||
Effects: require('./effects')
|
||||
|
||||
};
|
||||
|
|
|
@ -53,25 +53,25 @@ var CameraManager = new Class({
|
|||
*/
|
||||
this.cameras = [];
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -222,24 +222,39 @@ var CameraManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
|
||||
this.removeAll();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.scene = undefined;
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ var CONST = {
|
|||
* @type {string}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
VERSION: '3.4.0',
|
||||
VERSION: '3.5.0-beta',
|
||||
|
||||
BlendModes: require('./renderer/BlendModes'),
|
||||
|
||||
|
|
|
@ -92,7 +92,10 @@ var DataManager = new Class({
|
|||
*/
|
||||
this._frozen = false;
|
||||
|
||||
this.events.once('destroy', this.destroy, this);
|
||||
if (this.events)
|
||||
{
|
||||
this.events.once('destroy', this.destroy, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,6 +30,8 @@ var DataManagerPlugin = new Class({
|
|||
|
||||
function DataManagerPlugin (scene)
|
||||
{
|
||||
DataManager.call(this, scene, scene.sys.events);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -48,51 +50,63 @@ var DataManagerPlugin = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
DataManager.call(this, this.scene, scene.sys.events);
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Data.DataManagerPlugin#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
if (this.events)
|
||||
{
|
||||
this.events.off('destroy', this.destroy, this);
|
||||
}
|
||||
|
||||
this.events = this.systems.events;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#shutdown
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdownPlugin, this);
|
||||
eventEmitter.on('destroy', this.destroyPlugin, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#shutdownPlugin
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Data.DataManagerPlugin#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
shutdownPlugin: function ()
|
||||
destroy: function ()
|
||||
{
|
||||
// Should we reset the events?
|
||||
},
|
||||
DataManager.prototype.destroy.call(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#destroyPlugin
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroyPlugin: function ()
|
||||
{
|
||||
this.destroy();
|
||||
this.systems.events.off('start', this.start, this);
|
||||
|
||||
this.scene = undefined;
|
||||
this.systems = undefined;
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -134,7 +134,7 @@ function init ()
|
|||
OS.cordova = true;
|
||||
}
|
||||
|
||||
if ((typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined'))
|
||||
if (process && process.versions && process.versions.node)
|
||||
{
|
||||
OS.node = true;
|
||||
}
|
||||
|
|
|
@ -59,24 +59,24 @@ var DisplayList = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.GameObjects.DisplayList#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.DisplayList#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -157,6 +157,41 @@ var DisplayList = new Class({
|
|||
this.sortGameObjects(gameObjects);
|
||||
|
||||
return gameObjects[gameObjects.length - 1];
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.GameObjects.DisplayList#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.removeAll();
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.GameObjects.DisplayList#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -154,8 +154,23 @@ var GameObject = new Class({
|
|||
*/
|
||||
this.body = null;
|
||||
|
||||
/**
|
||||
* This Game Object will ignore all calls made to its destroy method if this flag is set to `true`.
|
||||
* This includes calls that may come from a Group, Container or the Scene itself.
|
||||
* While it allows you to persist a Game Object across Scenes, please understand you are entirely
|
||||
* responsible for managing references to and from this Game Object.
|
||||
*
|
||||
* @name Phaser.GameObjects.GameObject#ignoreDestroy
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.ignoreDestroy = false;
|
||||
|
||||
// Tell the Scene to re-sort the children
|
||||
this.scene.sys.queueDepthSort();
|
||||
scene.sys.queueDepthSort();
|
||||
|
||||
scene.sys.events.once('shutdown', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -375,7 +390,7 @@ var GameObject = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
// This Game Object had already been destroyed
|
||||
if (!this.scene)
|
||||
if (!this.scene || this.ignoreDestroy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -49,11 +49,6 @@ var GameObjectCreator = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to the Scene Display List.
|
||||
*
|
||||
|
@ -73,45 +68,61 @@ var GameObjectCreator = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.updateList;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Boots the plugin.
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#boot
|
||||
* @method Phaser.GameObjects.GameObjectCreator#start
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
this.displayList = this.systems.displayList;
|
||||
this.updateList = this.systems.updateList;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Shuts this plugin down.
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this plugin.
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
this.displayList = null;
|
||||
this.updateList = null;
|
||||
}
|
||||
|
|
|
@ -48,11 +48,6 @@ var GameObjectFactory = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to the Scene Display List.
|
||||
*
|
||||
|
@ -72,24 +67,28 @@ var GameObjectFactory = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.updateList;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Boots the plugin.
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#boot
|
||||
* @method Phaser.GameObjects.GameObjectFactory#start
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
this.displayList = this.systems.displayList;
|
||||
this.updateList = this.systems.updateList;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -121,24 +120,37 @@ var GameObjectFactory = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Shuts this plugin down.
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this plugin.
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
|
||||
this.displayList = null;
|
||||
this.updateList = null;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,6 @@ var UpdateList = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -79,22 +74,27 @@ var UpdateList = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this._pendingRemoval = [];
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.GameObjects.UpdateList#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.GameObjects.UpdateList#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('preupdate', this.preUpdate, this);
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -228,7 +228,8 @@ var UpdateList = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.GameObjects.UpdateList#shutdown
|
||||
* @since 3.0.0
|
||||
|
@ -240,10 +241,17 @@ var UpdateList = new Class({
|
|||
this._list.length = 0;
|
||||
this._pendingRemoval.length = 0;
|
||||
this._pendingInsertion.length = 0;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('preupdate', this.preUpdate, this);
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.GameObjects.UpdateList#destroy
|
||||
* @since 3.0.0
|
||||
|
@ -252,9 +260,10 @@ var UpdateList = new Class({
|
|||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene = undefined;
|
||||
this.systems = undefined;
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -116,6 +116,16 @@ var DynamicBitmapText = new Class({
|
|||
*/
|
||||
this.fontSize = size || this.fontData.size;
|
||||
|
||||
/**
|
||||
* Adds/Removes spacing between characters
|
||||
* Can be a negative or positive number
|
||||
*
|
||||
* @name Phaser.GameObjects.DynamicBitmapText#letterSpacing
|
||||
* @type {number}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.letterSpacing = 0;
|
||||
|
||||
this.setTexture(entry.texture, entry.frame);
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin(0, 0);
|
||||
|
|
|
@ -712,7 +712,7 @@ var Animation = new Class({
|
|||
* @fires Phaser.GameObjects.Components.Animation#onCompleteEvent
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {integer} delay - The number of miliseconds to wait before stopping this animation.
|
||||
* @param {integer} delay - The number of milliseconds to wait before stopping this animation.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component.
|
||||
*/
|
||||
|
@ -817,24 +817,26 @@ var Animation = new Class({
|
|||
*/
|
||||
update: function (timestamp, delta)
|
||||
{
|
||||
if (this.currentAnim && (this.isPlaying || !this.currentAnim.paused))
|
||||
if (!this.currentAnim || !this.isPlaying || this.currentAnim.paused)
|
||||
{
|
||||
this.accumulator += delta * this._timeScale;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._pendingStop === 1)
|
||||
this.accumulator += delta * this._timeScale;
|
||||
|
||||
if (this._pendingStop === 1)
|
||||
{
|
||||
this._pendingStopValue -= delta;
|
||||
|
||||
if (this._pendingStopValue <= 0)
|
||||
{
|
||||
this._pendingStopValue -= delta;
|
||||
|
||||
if (this._pendingStopValue <= 0)
|
||||
{
|
||||
return this.currentAnim.completeAnimation(this);
|
||||
}
|
||||
return this.currentAnim.completeAnimation(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.accumulator >= this.nextTick)
|
||||
{
|
||||
this.currentAnim.setFrame(this);
|
||||
}
|
||||
if (this.accumulator >= this.nextTick)
|
||||
{
|
||||
this.currentAnim.setFrame(this);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -51,12 +51,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getTopLeft: function (output)
|
||||
getTopLeft: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = this.x - (this.displayWidth * this.originX);
|
||||
output.y = this.y - (this.displayHeight * this.originY);
|
||||
|
@ -66,6 +68,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -79,12 +88,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getTopRight: function (output)
|
||||
getTopRight: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth;
|
||||
output.y = this.y - (this.displayHeight * this.originY);
|
||||
|
@ -94,6 +105,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -107,12 +125,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getBottomLeft: function (output)
|
||||
getBottomLeft: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = this.x - (this.displayWidth * this.originX);
|
||||
output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight;
|
||||
|
@ -122,6 +142,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -135,12 +162,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getBottomRight: function (output)
|
||||
getBottomRight: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth;
|
||||
output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight;
|
||||
|
@ -150,6 +179,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
|
|
@ -18,6 +18,11 @@ var Vector2 = require('../../math/Vector2');
|
|||
* @classdesc
|
||||
* A Container Game Object.
|
||||
*
|
||||
* WARNING: EXPERIMENTAL. There are several known cases where Containers will not behave correctly,
|
||||
* especially if you use a multi-camera or transformed camera set-up. We are still working on them,
|
||||
* but wanted to release as part of 3.4 under a beta feature flag, because in the main they work
|
||||
* are and worth getting used to.
|
||||
*
|
||||
* A Container, as the name implies, can 'contain' other types of Game Object.
|
||||
* When a Game Object is added to a Container, the Container becomes responsible for the rendering of it.
|
||||
* By default it will be removed from the Display List and instead added to the Containers own internal list.
|
||||
|
@ -1210,7 +1215,7 @@ var Container = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.removeAll(this.exclusive);
|
||||
this.removeAll(!!this.exclusive);
|
||||
|
||||
this.localTransform.destroy();
|
||||
this.tempTransformMatrix.destroy();
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
var Container = require('./Container');
|
||||
var GameObjectFactory = require('../GameObjectFactory');
|
||||
|
||||
var hasWarned = false;
|
||||
|
||||
/**
|
||||
* Creates a new Container Game Object and adds it to the Scene.
|
||||
*
|
||||
|
@ -18,11 +20,17 @@ var GameObjectFactory = require('../GameObjectFactory');
|
|||
*
|
||||
* @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.
|
||||
* @param {Phaser.GameObjects.GameObject|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)
|
||||
{
|
||||
if (!hasWarned)
|
||||
{
|
||||
console.warn('Use of a beta feature: Containers');
|
||||
hasWarned = true;
|
||||
}
|
||||
|
||||
return this.displayList.add(new Container(this.scene, x, y, children));
|
||||
});
|
||||
|
|
|
@ -15,79 +15,100 @@ var Sprite = require('../sprite/Sprite');
|
|||
/**
|
||||
* @callback GroupCallback
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} item - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} item - A group member
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback GroupMultipleCreateCallback
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject[]} items - [description]
|
||||
* @param {Phaser.GameObjects.GameObject[]} items - The newly created group members
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} GroupConfig
|
||||
*
|
||||
* @property {object} [classType=Sprite] - [description]
|
||||
* @property {boolean} [active=true] - [description]
|
||||
* @property {number} [maxSize=-1] - [description]
|
||||
* @property {?string} [defaultKey=null] - [description]
|
||||
* @property {?(string|integer)} [defaultFrame=null] - [description]
|
||||
* @property {boolean} [runChildUpdate=false] - [description]
|
||||
* @property {?GroupCallback} [createCallback=null] - [description]
|
||||
* @property {?GroupCallback} [removeCallback=null] - [description]
|
||||
* @property {?GroupMultipleCreateCallback} [createMultipleCallback=null] - [description]
|
||||
* @property {?object} [classType=Sprite] - Sets {@link Phaser.GameObjects.Group#classType}.
|
||||
* @property {?boolean} [active=true] - Sets {@link Phaser.GameObjects.Group#active}.
|
||||
* @property {?number} [maxSize=-1] - Sets {@link Phaser.GameObjects.Group#maxSize}.
|
||||
* @property {?string} [defaultKey=null] - Sets {@link Phaser.GameObjects.Group#defaultKey}.
|
||||
* @property {?(string|integer)} [defaultFrame=null] - Sets {@link Phaser.GameObjects.Group#defaultFrame}.
|
||||
* @property {?boolean} [runChildUpdate=false] - Sets {@link Phaser.GameObjects.Group#runChildUpdate}.
|
||||
* @property {?GroupCallback} [createCallback=null] - Sets {@link Phaser.GameObjects.Group#createCallback}.
|
||||
* @property {?GroupCallback} [removeCallback=null] - Sets {@link Phaser.GameObjects.Group#removeCallback}.
|
||||
* @property {?GroupMultipleCreateCallback} [createMultipleCallback=null] - Sets {@link Phaser.GameObjects.Group#createMultipleCallback}.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} GroupCreateConfig
|
||||
*
|
||||
* @property {object} [classType] - [description]
|
||||
* @property {string} [key] - [description]
|
||||
* @property {?(string|integer)} [frame=null] - [description]
|
||||
* @property {boolean} [visible=true] - [description]
|
||||
* @property {boolean} [active=true] - [description]
|
||||
* @property {number} [repeat=0] - [description]
|
||||
* @property {boolean} [randomKey=false] - [description]
|
||||
* @property {boolean} [randomFrame=false] - [description]
|
||||
* @property {boolean} [yoyo=false] - [description]
|
||||
* @property {number} [frameQuantity=1] - [description]
|
||||
* @property {number} [max=1] - [description]
|
||||
* @property {object} [setXY] - [description]
|
||||
* @property {number} [setXY.x=0] - [description]
|
||||
* @property {number} [setXY.y=0] - [description]
|
||||
* @property {number} [setXY.stepX=0] - [description]
|
||||
* @property {number} [setXY.stepY=0] - [description]
|
||||
* @property {object} [setRotation] - [description]
|
||||
* @property {number} [setRotation.value=0] - [description]
|
||||
* @property {number} [setRotation.step=0] - [description]
|
||||
* @property {object} [setScale] - [description]
|
||||
* @property {number} [setScale.x=0] - [description]
|
||||
* @property {number} [setScale.y=0] - [description]
|
||||
* @property {number} [setScale.stepX=0] - [description]
|
||||
* @property {number} [setScale.stepY=0] - [description]
|
||||
* @property {object} [setAlpha] - [description]
|
||||
* @property {number} [setAlpha.value=0] - [description]
|
||||
* @property {number} [setAlpha.step=0] - [description]
|
||||
* @property {*} [hitArea] - [description]
|
||||
* @property {HitAreaCallback} [hitAreaCallback] - [description]
|
||||
* @property {(false|GridAlignConfig)} [gridAlign=false] - [description]
|
||||
* The total number of objects created will be
|
||||
*
|
||||
* key.length * frame.length * frameQuantity * (yoyo ? 2 : 1) * (1 + repeat)
|
||||
*
|
||||
* In the simplest case, 1 + `repeat` objects will be created.
|
||||
*
|
||||
* If `max` is positive, then the total created will not exceed `max`.
|
||||
*
|
||||
* `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used.
|
||||
*
|
||||
* @property {?object} [classType] - The class of each new Game Object.
|
||||
* @property {string} [key] - The texture key of each new Game Object.
|
||||
* @property {?(string|integer)} [frame=null] - The texture frame of each new Game Object.
|
||||
* @property {?boolean} [visible=true] - The visible state of each new Game Object.
|
||||
* @property {?boolean} [active=true] - The active state of each new Game Object.
|
||||
* @property {?number} [repeat=0] - The number of times each `key` × `frame` combination will be *repeated* (after the first combination).
|
||||
* @property {?boolean} [randomKey=false] - Select a `key` at random.
|
||||
* @property {?boolean} [randomFrame=false] - Select a `frame` at random.
|
||||
* @property {?boolean} [yoyo=false] - Select keys and frames by moving forward then backward through `key` and `frame`.
|
||||
* @property {?number} [frameQuantity=1] - The number of times each `frame` should be combined with one `key`.
|
||||
* @property {?number} [max=0] - The maximum number of new Game Objects to create. 0 is no maximum.
|
||||
* @property {?object} [setXY]
|
||||
* @property {?number} [setXY.x=0] - The horizontal position of each new Game Object.
|
||||
* @property {?number} [setXY.y=0] - The vertical position of each new Game Object.
|
||||
* @property {?number} [setXY.stepX=0] - Increment each Game Object's horizontal position from the previous by this amount, starting from `setXY.x`.
|
||||
* @property {?number} [setXY.stepY=0] - Increment each Game Object's vertical position from the previous by this amount, starting from `setXY.y`.
|
||||
* @property {?object} [setRotation]
|
||||
* @property {?number} [setRotation.value=0] - Rotation of each new Game Object.
|
||||
* @property {?number} [setRotation.step=0] - Increment each Game Object's rotation from the previous by this amount, starting at `setRotation.value`.
|
||||
* @property {?object} [setScale]
|
||||
* @property {?number} [setScale.x=0] - The horizontal scale of each new Game Object.
|
||||
* @property {?number} [setScale.y=0] - The vertical scale of each new Game Object.
|
||||
* @property {?number} [setScale.stepX=0] - Increment each Game Object's horizontal scale from the previous by this amount, starting from `setScale.x`.
|
||||
* @property {?number} [setScale.stepY=0] - Increment each Game object's vertical scale from the previous by this amount, starting from `setScale.y`.
|
||||
* @property {?object} [setAlpha]
|
||||
* @property {?number} [setAlpha.value=0] - The alpha value of each new Game Object.
|
||||
* @property {?number} [setAlpha.step=0] - Increment each Game Object's alpha from the previous by this amount, starting from `setAlpha.value`.
|
||||
* @property {?*} [hitArea] - A geometric shape that defines the hit area for the Game Object.
|
||||
* @property {?HitAreaCallback} [hitAreaCallback] - A callback to be invoked when the Game Object is interacted with.
|
||||
* @property {?(false|GridAlignConfig)} [gridAlign=false] - Align the new Game Objects in a grid using these settings.
|
||||
*
|
||||
* @see Phaser.Actions.GridAlign
|
||||
* @see Phaser.Actions.SetAlpha
|
||||
* @see Phaser.Actions.SetHitArea
|
||||
* @see Phaser.Actions.SetRotation
|
||||
* @see Phaser.Actions.SetScale
|
||||
* @see Phaser.Actions.SetXY
|
||||
* @see Phaser.GameObjects.Group#createFromConfig
|
||||
* @see Phaser.Utils.Array.Range
|
||||
*/
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
* @classdesc A Group is a way for you to create, manipulate, or recycle similar Game Objects.
|
||||
*
|
||||
* children can be either an array of children, or a config object
|
||||
* config can be either a config object, or undefined if passed as the children argument instead
|
||||
* Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none.
|
||||
*
|
||||
* Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden.
|
||||
*
|
||||
* @class Group
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
* @param {Phaser.Scene} scene - The scene this group belongs to.
|
||||
* @param {?(Phaser.GameObjects.GameObject[]|GroupConfig)} [children] - Game objects to add to this group; or the `config` argument.
|
||||
* @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings.
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {?(Phaser.GameObjects.GameObject[]|GroupConfig)} children - [description]
|
||||
* @param {GroupConfig} [config] - [description]
|
||||
* @see Phaser.Physics.Arcade.Group
|
||||
* @see Phaser.Physics.Arcade.StaticGroup
|
||||
*/
|
||||
var Group = new Class({
|
||||
|
||||
|
@ -102,7 +123,7 @@ var Group = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This scene this group belongs to.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#scene
|
||||
* @type {Phaser.Scene}
|
||||
|
@ -111,7 +132,7 @@ var Group = new Class({
|
|||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Members of this group.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#children
|
||||
* @type {Phaser.Structs.Set.<Phaser.GameObjects.GameObject>}
|
||||
|
@ -120,7 +141,7 @@ var Group = new Class({
|
|||
this.children = new Set(children);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A flag identifying this object as a group.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#isParent
|
||||
* @type {boolean}
|
||||
|
@ -130,16 +151,18 @@ var Group = new Class({
|
|||
this.isParent = true;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The class to create new group members from.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#classType
|
||||
* @type {object}
|
||||
* @since 3.0.0
|
||||
* @default Phaser.GameObjects.Sprite
|
||||
*/
|
||||
this.classType = GetFastValue(config, 'classType', Sprite);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method
|
||||
* (which may update any members).
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#active
|
||||
* @type {boolean}
|
||||
|
@ -148,16 +171,20 @@ var Group = new Class({
|
|||
this.active = GetFastValue(config, 'active', true);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The maximum size of this group, if used as a pool. -1 is no limit.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#maxSize
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
* @default -1
|
||||
*/
|
||||
this.maxSize = GetFastValue(config, 'maxSize', -1);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A default texture key to use when creating new group members.
|
||||
*
|
||||
* This is used in {@link Phaser.GameObjects.Group#create}
|
||||
* but not in {@link Phaser.GameObjects.Group#createMultiple}.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#defaultKey
|
||||
* @type {string}
|
||||
|
@ -166,7 +193,7 @@ var Group = new Class({
|
|||
this.defaultKey = GetFastValue(config, 'defaultKey', null);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A default texture frame to use when creating new group members.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#defaultFrame
|
||||
* @type {(string|integer)}
|
||||
|
@ -175,17 +202,18 @@ var Group = new Class({
|
|||
this.defaultFrame = GetFastValue(config, 'defaultFrame', null);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether to call the update method of any members.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#runChildUpdate
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
* @see Phaser.GameObjects.Group#preUpdate
|
||||
*/
|
||||
this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A function to be called when adding or creating group members.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#createCallback
|
||||
* @type {?GroupCallback}
|
||||
|
@ -194,7 +222,7 @@ var Group = new Class({
|
|||
this.createCallback = GetFastValue(config, 'createCallback', null);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A function to be called when removing group members.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#removeCallback
|
||||
* @type {?GroupCallback}
|
||||
|
@ -203,7 +231,7 @@ var Group = new Class({
|
|||
this.removeCallback = GetFastValue(config, 'removeCallback', null);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A function to be called when creating several group members at once.
|
||||
*
|
||||
* @name Phaser.GameObjects.Group#createMultipleCallback
|
||||
* @type {?GroupMultipleCreateCallback}
|
||||
|
@ -211,26 +239,28 @@ var Group = new Class({
|
|||
*/
|
||||
this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null);
|
||||
|
||||
if (config)
|
||||
if (config && config.key !== undefined)
|
||||
{
|
||||
this.createMultiple(config);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates a new Game Object and adds it to this group, unless the group {@link Phaser.GameObjects.Group#isFull is full}.
|
||||
*
|
||||
* Calls {@link Phaser.GameObjects.Group#createCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#create
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @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 {string} [key=defaultKey] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object.
|
||||
* @param {boolean} [active=true] - The {@link Phaser.GameObjects.GameObject#active} state of this Game Object.
|
||||
* @param {number} [x=0] - The horizontal position of the new Game Object in the world.
|
||||
* @param {number} [y=0] - The vertical position of the new Game Object in the world.
|
||||
* @param {string} [key=defaultKey] - The texture key of the new Game Object.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - The texture frame of the new Game Object.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object.
|
||||
* @param {boolean} [active=true] - The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The new Game Object.
|
||||
*/
|
||||
create: function (x, y, key, frame, visible, active)
|
||||
{
|
||||
|
@ -265,17 +295,27 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates several Game Objects and adds them to this group.
|
||||
*
|
||||
* If the group becomes {@link Phaser.GameObjects.Group#isFull}, no further Game Objects are created.
|
||||
*
|
||||
* Calls {@link Phaser.GameObjects.Group#createMultipleCallback}
|
||||
* and {@link Phaser.GameObjects.Group#createCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#createMultiple
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {GroupCreateConfig} config - [description]
|
||||
* @param {GroupCreateConfig|GroupCreateConfig[]} config - Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject[]} [description]
|
||||
* @return {Phaser.GameObjects.GameObject[]} The newly created Game Objects.
|
||||
*/
|
||||
createMultiple: function (config)
|
||||
{
|
||||
if (this.isFull())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!Array.isArray(config))
|
||||
{
|
||||
config = [ config ];
|
||||
|
@ -294,17 +334,22 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A helper for {@link Phaser.GameObjects.Group#createMultiple}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#createFromConfig
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {GroupCreateConfig} options - [description]
|
||||
* @param {GroupCreateConfig} options - Creation settings.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject[]} [description]
|
||||
* @return {Phaser.GameObjects.GameObject[]} The newly created Game Objects.
|
||||
*/
|
||||
createFromConfig: function (options)
|
||||
{
|
||||
if (this.isFull())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
this.classType = GetFastValue(options, 'classType', this.classType);
|
||||
|
||||
var key = GetFastValue(options, 'key', undefined);
|
||||
|
@ -354,7 +399,14 @@ var Group = new Class({
|
|||
|
||||
for (var c = 0; c < range.length; c++)
|
||||
{
|
||||
entries.push(this.create(0, 0, range[c].a, range[c].b, visible, active));
|
||||
var created = this.create(0, 0, range[c].a, range[c].b, visible, active);
|
||||
|
||||
if (!created)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
entries.push(created);
|
||||
}
|
||||
|
||||
// Post-creation options (applied only to those items created in this call):
|
||||
|
@ -407,13 +459,13 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#preUpdate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
* @param {number} time - The current timestamp.
|
||||
* @param {number} delta - The delta time elapsed since the last frame.
|
||||
*/
|
||||
preUpdate: function (time, delta)
|
||||
{
|
||||
|
@ -437,13 +489,15 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Adds a Game Object to this group.
|
||||
*
|
||||
* Calls {@link Phaser.GameObjects.Group#createCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {boolean} [addToScene=false] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The Game Object to add.
|
||||
* @param {boolean} [addToScene=false] - Also add the Game Object to the scene.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
*/
|
||||
|
@ -451,6 +505,11 @@ var Group = new Class({
|
|||
{
|
||||
if (addToScene === undefined) { addToScene = false; }
|
||||
|
||||
if (this.isFull())
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
this.children.set(child);
|
||||
|
||||
if (this.createCallback)
|
||||
|
@ -474,15 +533,17 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Adds several Game Objects to this group.
|
||||
*
|
||||
* Calls {@link Phaser.GameObjects.Group#createCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#addMultiple
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject[]} children - [description]
|
||||
* @param {boolean} [addToScene=false] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject[]} children - The Game Objects to add.
|
||||
* @param {boolean} [addToScene=false] - Also add the Game Objects to the scene.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
* @return {Phaser.GameObjects.Group} This group.
|
||||
*/
|
||||
addMultiple: function (children, addToScene)
|
||||
{
|
||||
|
@ -500,13 +561,15 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Removes a member of this group.
|
||||
*
|
||||
* Calls {@link Phaser.GameObjects.Group#removeCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {boolean} [removeFromScene=false] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The Game Object to remove.
|
||||
* @param {boolean} [removeFromScene=false] - Also remove the group member from the scene.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
*/
|
||||
|
@ -514,6 +577,11 @@ var Group = new Class({
|
|||
{
|
||||
if (removeFromScene === undefined) { removeFromScene = false; }
|
||||
|
||||
if (!this.children.contains(child))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
this.children.delete(child);
|
||||
|
||||
if (this.removeCallback)
|
||||
|
@ -537,14 +605,16 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Removes all members of this group.
|
||||
*
|
||||
* Does not call {@link Phaser.GameObjects.Group#removeCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#clear
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [removeFromScene=false] - [description]
|
||||
* @param {boolean} [removeFromScene=false] - Also remove each group member from the scene.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
* @return {Phaser.GameObjects.Group} This group.
|
||||
*/
|
||||
clear: function (removeFromScene)
|
||||
{
|
||||
|
@ -575,14 +645,14 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Tests if a Game Object is a member of this group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#contains
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - A Game Object.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} True if the Game Object is a member of this group.
|
||||
*/
|
||||
contains: function (child)
|
||||
{
|
||||
|
@ -590,12 +660,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* All members of the group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getChildren
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject[]} [description]
|
||||
* @return {Phaser.GameObjects.GameObject[]} The group members.
|
||||
*/
|
||||
getChildren: function ()
|
||||
{
|
||||
|
@ -603,12 +673,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The number of members of the group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getLength
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @return {integer}
|
||||
*/
|
||||
getLength: function ()
|
||||
{
|
||||
|
@ -616,20 +686,24 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state matching the argument,
|
||||
* assigns `x` and `y`, and returns the member.
|
||||
*
|
||||
* If no matching member is found and `createIfNull` is true and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`.
|
||||
* Unless a new member is created, `key`, `frame`, and `visible` are ignored.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getFirst
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [state=false] - [description]
|
||||
* @param {boolean} [createIfNull=false] - [description]
|
||||
* @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 {string} [key=defaultKey] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object.
|
||||
* @param {boolean} [state=false] - The {@link Phaser.GameObjects.GameObject#active} value to match.
|
||||
* @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments.
|
||||
* @param {number} [x] - The horizontal position of the Game Object in the world.
|
||||
* @param {number} [y] - The vertical position of the Game Object in the world.
|
||||
* @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created).
|
||||
* @param {(string|integer)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created).
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).
|
||||
*
|
||||
* @return {?Phaser.GameObjects.GameObject} [description]
|
||||
* @return {?Phaser.GameObjects.GameObject} The first matching group member, or a newly created member, or null.
|
||||
*/
|
||||
getFirst: function (state, createIfNull, x, y, key, frame, visible)
|
||||
{
|
||||
|
@ -672,21 +746,23 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Scans the Group for the first child that has an `active` state set to `false` and returns it.
|
||||
*
|
||||
* If no child is found then it will create a new one using the arguments given to this method.
|
||||
* Unless a new child is being created the arguments are ignored.
|
||||
* Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`,
|
||||
* assigns `x` and `y`, and returns the member.
|
||||
*
|
||||
* If no inactive member is found and the group isn't full then it will create a new Game Object using `x`, `y`, `key`, `frame`, and `visible`.
|
||||
* The new Game Object will have its active state set to `true`.
|
||||
* Unless a new member is created, `key`, `frame`, and `visible` are ignored.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#get
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @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 {string} [key=defaultKey] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object.
|
||||
* @param {number} [x] - The horizontal position of the Game Object in the world.
|
||||
* @param {number} [y] - The vertical position of the Game Object in the world.
|
||||
* @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created).
|
||||
* @param {(string|integer)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created).
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {?Phaser.GameObjects.GameObject} The first inactive group member, or a newly created member, or null.
|
||||
*/
|
||||
get: function (x, y, key, frame, visible)
|
||||
{
|
||||
|
@ -694,22 +770,23 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Scans the Group for the first child that has an `active` state set to `true` and returns it.
|
||||
*
|
||||
* If no child is found, and `createIfNull` is `true`, then it will create a new one using the arguments given to this method.
|
||||
* Unless a new child is being created the arguments are ignored.
|
||||
* Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `true`,
|
||||
* assigns `x` and `y`, and returns the member.
|
||||
*
|
||||
* If no active member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`.
|
||||
* Unless a new member is created, `key`, `frame`, and `visible` are ignored.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getFirstAlive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} createIfNull - [description]
|
||||
* @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 {string} [key=defaultKey] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object.
|
||||
* @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments.
|
||||
* @param {number} [x] - The horizontal position of the Game Object in the world.
|
||||
* @param {number} [y] - The vertical position of the Game Object in the world.
|
||||
* @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created).
|
||||
* @param {(string|integer)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created).
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The first active group member, or a newly created member, or null.
|
||||
*/
|
||||
getFirstAlive: function (createIfNull, x, y, key, frame, visible)
|
||||
{
|
||||
|
@ -717,22 +794,24 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Scans the Group for the first child that has an `active` state set to `false` and returns it.
|
||||
*
|
||||
* If no child is found, and `createIfNull` is `true`, then it will create a new one using the arguments given to this method.
|
||||
* Unless a new child is being created the arguments are ignored.
|
||||
* Scans the group for the first member that has an {@link Phaser.GameObjects.GameObject#active} state set to `false`,
|
||||
* assigns `x` and `y`, and returns the member.
|
||||
*
|
||||
* If no inactive member is found and `createIfNull` is `true` and the group isn't full then it will create a new one using `x`, `y`, `key`, `frame`, and `visible`.
|
||||
* The new Game Object will have an active state set to `true`.
|
||||
* Unless a new member is created, `key`, `frame`, and `visible` are ignored.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getFirstDead
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} createIfNull - [description]
|
||||
* @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 {string} [key=defaultKey] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {(string|integer)} [frame=defaultFrame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object.
|
||||
* @param {boolean} [createIfNull=false] - Create a new Game Object if no matching members are found, using the following arguments.
|
||||
* @param {number} [x] - The horizontal position of the Game Object in the world.
|
||||
* @param {number} [y] - The vertical position of the Game Object in the world.
|
||||
* @param {string} [key=defaultKey] - The texture key assigned to a new Game Object (if one is created).
|
||||
* @param {(string|integer)} [frame=defaultFrame] - A texture frame assigned to a new Game Object (if one is created).
|
||||
* @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The first inactive group member, or a newly created member, or null.
|
||||
*/
|
||||
getFirstDead: function (createIfNull, x, y, key, frame, visible)
|
||||
{
|
||||
|
@ -740,13 +819,13 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#playAnimation
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} startFrame - [description]
|
||||
* @param {string} key - The string-based key of the animation to play.
|
||||
* @param {string} [startFrame=0] - Optionally start the animation playing from this frame index.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
*/
|
||||
|
@ -758,12 +837,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#isFull
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} True if the number of members equals {@link Phaser.GameObjects.Group#maxSize}.
|
||||
*/
|
||||
isFull: function ()
|
||||
{
|
||||
|
@ -773,19 +852,19 @@ var Group = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
return (this.children.size === this.maxSize);
|
||||
return (this.children.size >= this.maxSize);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Counts the number of active (or inactive) group members.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#countActive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [value=true] - [description]
|
||||
* @param {boolean} [value=true] - Count active (true) or inactive (false) group members.
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @return {integer} The number of group members with an active state matching the `active` argument.
|
||||
*/
|
||||
countActive: function (value)
|
||||
{
|
||||
|
@ -805,12 +884,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Counts the number of in-use (active) group members.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getTotalUsed
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @return {integer} The number of group members with an active state of true.
|
||||
*/
|
||||
getTotalUsed: function ()
|
||||
{
|
||||
|
@ -818,12 +897,14 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The difference of {@link Phaser.GameObjects.Group#maxSize} and the number of active group members.
|
||||
*
|
||||
* This represents the number of group members that could be created or reactivated before reaching the size limit.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#getTotalFree
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
* @return {integer} maxSize minus the number of active group numbers; or a large number (if maxSize is -1).
|
||||
*/
|
||||
getTotalFree: function ()
|
||||
{
|
||||
|
@ -834,13 +915,13 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the depth of each group member.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#setDepth
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} value - [description]
|
||||
* @param {number} step - [description]
|
||||
* @param {number} value - The amount to set the property to.
|
||||
* @param {number} step - This is added to the `value` amount, multiplied by the iteration counter.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Group} This Group object.
|
||||
*/
|
||||
|
@ -852,12 +933,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Deactivates a member of this group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#kill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - A member of this group.
|
||||
*/
|
||||
kill: function (gameObject)
|
||||
{
|
||||
|
@ -868,12 +949,12 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Deactivates and hides a member of this group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#killAndHide
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - A member of this group.
|
||||
*/
|
||||
killAndHide: function (gameObject)
|
||||
{
|
||||
|
@ -885,7 +966,7 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Toggles (flips) the visible state of each member of this group.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#toggleVisible
|
||||
* @since 3.0.0
|
||||
|
@ -900,12 +981,14 @@ var Group = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Empties this group and removes it from the scene.
|
||||
*
|
||||
* Does not call {@link Phaser.GameObjects.Group#removeCallback}.
|
||||
*
|
||||
* @method Phaser.GameObjects.Group#destroy
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [destroyChildren=false] - Call `GameObject.destroy` on all children of this Group?
|
||||
* @param {boolean} [destroyChildren=false] - Also {@link Phaser.GameObjects.GameObject#destroy} each group member.
|
||||
*/
|
||||
destroy: function (destroyChildren)
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ var RenderTexture = new Class({
|
|||
this.clear = RenderTextureCanvas.clear;
|
||||
this.draw = RenderTextureCanvas.draw;
|
||||
this.drawFrame = RenderTextureCanvas.drawFrame;
|
||||
this.canvas = CanvasPool.create2D(null, width, height);
|
||||
this.canvas = CanvasPool.create2D(this, width, height);
|
||||
this.context = this.canvas.getContext('2d');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ var RenderTextureWebGL = {
|
|||
var glTexture = texture.source[frame.sourceIndex].glTexture;
|
||||
var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16);
|
||||
this.renderer.setFramebuffer(this.framebuffer);
|
||||
this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix);
|
||||
this.renderer.pipelines.TextureTintPipeline.projOrtho(0, this.renderer.pipelines.TextureTintPipeline.width, 0, this.renderer.pipelines.TextureTintPipeline.height, -1000.0, 1000.0);
|
||||
this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix, null, this);
|
||||
this.renderer.setFramebuffer(null);
|
||||
this.renderer.pipelines.TextureTintPipeline.projOrtho(0, this.renderer.pipelines.TextureTintPipeline.width, this.renderer.pipelines.TextureTintPipeline.height, 0, -1000.0, 1000.0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolatio
|
|||
renderTexture.width, renderTexture.height,
|
||||
renderTexture.scaleX, renderTexture.scaleY,
|
||||
renderTexture.rotation,
|
||||
renderTexture.flipX, renderTexture.flipY,
|
||||
renderTexture.flipX, !renderTexture.flipY,
|
||||
renderTexture.scrollFactorX, renderTexture.scrollFactorY,
|
||||
renderTexture.displayOriginX, renderTexture.displayOriginY,
|
||||
0, 0, renderTexture.texture.width, renderTexture.texture.height,
|
||||
|
|
|
@ -165,7 +165,7 @@ var TileSprite = new Class({
|
|||
* @type {HTMLCanvasElement}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.canvasBuffer = CanvasPool.create2D(null, this.potWidth, this.potHeight);
|
||||
this.canvasBuffer = CanvasPool.create2D(this, this.potWidth, this.potHeight);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
|
|
|
@ -410,7 +410,7 @@ var InputManager = new Class({
|
|||
|
||||
if (gameObject.parentContainer)
|
||||
{
|
||||
gameObject.getWorldTransformMatrix(matrix, camera);
|
||||
gameObject.getWorldTransformMatrix(matrix);
|
||||
|
||||
TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point);
|
||||
}
|
||||
|
@ -428,6 +428,7 @@ var InputManager = new Class({
|
|||
return output;
|
||||
},
|
||||
|
||||
/*
|
||||
debugHitTest: function (x, y, gameObject, camera, output)
|
||||
{
|
||||
if (output === undefined) { output = this._tempHitTest; }
|
||||
|
@ -448,7 +449,7 @@ var InputManager = new Class({
|
|||
|
||||
gameObject.getWorldTransformMatrix(matrix);
|
||||
|
||||
matrix.invert();
|
||||
// matrix.invert();
|
||||
matrix.transformPoint(px, py, point);
|
||||
|
||||
// var tt = new TransformMatrix();
|
||||
|
@ -465,6 +466,7 @@ var InputManager = new Class({
|
|||
|
||||
return [ matrix, point, this.pointWithinHitArea(gameObject, point.x, point.y) ];
|
||||
},
|
||||
*/
|
||||
|
||||
/**
|
||||
* x/y MUST be translated before being passed to this function,
|
||||
|
|
|
@ -58,10 +58,14 @@ var InputPlugin = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Input.InputPlugin#settings
|
||||
* @type {SettingsObject}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.settings = scene.sys.settings;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
|
@ -72,6 +76,16 @@ var InputPlugin = new Class({
|
|||
*/
|
||||
this.manager = scene.sys.game.input;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Input.InputPlugin#enabled
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.enabled = true;
|
||||
|
||||
/**
|
||||
* A reference to this.scene.sys.displayList (set in boot)
|
||||
*
|
||||
|
@ -268,22 +282,33 @@ var InputPlugin = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ];
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Input.InputPlugin#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('transitionstart', this.transitionIn, this);
|
||||
eventEmitter.on('transitionout', this.transitionOut, this);
|
||||
eventEmitter.on('transitioncomplete', this.transitionComplete, this);
|
||||
eventEmitter.on('preupdate', this.preUpdate, this);
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.cameras = this.systems.cameras;
|
||||
|
||||
|
@ -1434,8 +1459,8 @@ var InputPlugin = new Class({
|
|||
{
|
||||
var manager = this.manager;
|
||||
|
||||
// Another Scene above this one has already consumed the input events
|
||||
if (manager.globalTopOnly && manager.ignoreEvents)
|
||||
// Another Scene above this one has already consumed the input events, or we're in transition
|
||||
if (!this.enabled || (manager.globalTopOnly && manager.ignoreEvents))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1514,10 +1539,51 @@ var InputPlugin = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is transitioning in.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#transitionIn
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
transitionIn: function ()
|
||||
{
|
||||
this.enabled = this.settings.transitionAllowInput;
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin has finished transitioning in.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#transitionComplete
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
transitionComplete: function ()
|
||||
{
|
||||
if (!this.settings.transitionAllowInput)
|
||||
{
|
||||
this.enabled = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is transitioning out.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#transitionOut
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
transitionOut: function ()
|
||||
{
|
||||
this.enabled = this.settings.transitionAllowInput;
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
|
@ -1535,25 +1601,39 @@ var InputPlugin = new Class({
|
|||
}
|
||||
|
||||
this.removeAllListeners();
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('transitionstart', this.transitionIn, this);
|
||||
eventEmitter.off('transitionout', this.transitionOut, this);
|
||||
eventEmitter.off('transitioncomplete', this.transitionComplete, this);
|
||||
|
||||
eventEmitter.off('preupdate', this.preUpdate, this);
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene = undefined;
|
||||
this.cameras = undefined;
|
||||
this.manager = undefined;
|
||||
this.events = undefined;
|
||||
this.keyboard = undefined;
|
||||
this.mouse = undefined;
|
||||
this.gamepad = undefined;
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.cameras = null;
|
||||
this.manager = null;
|
||||
this.events = null;
|
||||
this.keyboard = null;
|
||||
this.mouse = null;
|
||||
this.gamepad = null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,11 +84,6 @@ var LoaderPlugin = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -245,20 +240,25 @@ var LoaderPlugin = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.state = CONST.LOADER_IDLE;
|
||||
|
||||
scene.sys.events.on('start', this.boot, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Loader.LoaderPlugin#boot
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -976,27 +976,48 @@ var LoaderPlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Loader.LoaderPlugin#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.reset();
|
||||
|
||||
this.state = CONST.LOADER_SHUTDOWN;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Loader.LoaderPlugin#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
this.shutdown();
|
||||
|
||||
this.state = CONST.LOADER_DESTROYED;
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.list = null;
|
||||
this.inflight = null;
|
||||
this.failed = null;
|
||||
this.queue = null;
|
||||
this.storage = null;
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -122,7 +122,7 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
|
|||
}
|
||||
else
|
||||
{
|
||||
return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked);
|
||||
return new HTML5AudioFile(key, url, loader.path, config);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ var GetURL = require('../GetURL');
|
|||
* @param {string} url - [description]
|
||||
* @param {string} path - [description]
|
||||
* @param {XHRSettingsObject} config - [description]
|
||||
* @param {boolean} locked - [description]
|
||||
*/
|
||||
var HTML5AudioFile = new Class({
|
||||
|
||||
|
@ -31,9 +30,9 @@ var HTML5AudioFile = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function HTML5AudioFile (key, url, path, config, locked)
|
||||
function HTML5AudioFile (key, url, path, config)
|
||||
{
|
||||
this.locked = locked;
|
||||
this.locked = 'ontouchstart' in window;
|
||||
|
||||
this.loaded = false;
|
||||
|
||||
|
@ -110,8 +109,14 @@ var HTML5AudioFile = new Class({
|
|||
audio.dataset.name = this.key + ('0' + i).slice(-2); // Useful for debugging
|
||||
audio.dataset.used = 'false';
|
||||
|
||||
if (!this.locked)
|
||||
if (this.locked)
|
||||
{
|
||||
audio.dataset.locked = 'true';
|
||||
}
|
||||
else
|
||||
{
|
||||
audio.dataset.locked = 'false';
|
||||
|
||||
audio.preload = 'auto';
|
||||
audio.oncanplaythrough = this.onProgress.bind(this);
|
||||
audio.onerror = this.onError.bind(this);
|
||||
|
|
|
@ -10,8 +10,8 @@ var CONST = require('./const');
|
|||
var Extend = require('./utils/object/Extend');
|
||||
|
||||
/**
|
||||
* @namespace Phaser
|
||||
*/
|
||||
* @namespace Phaser
|
||||
*/
|
||||
|
||||
var Phaser = {
|
||||
|
||||
|
@ -58,7 +58,7 @@ module.exports = Phaser;
|
|||
global.Phaser = Phaser;
|
||||
|
||||
/*
|
||||
* "Documentation is like sex: when it is good, it is very, very good;
|
||||
* "Documentation is like pizza: when it is good, it is very, very good;
|
||||
* and when it is bad, it is better than nothing."
|
||||
* -- Dick Brandon
|
||||
*/
|
||||
|
|
101
src/phaser-core.js
Normal file
101
src/phaser-core.js
Normal file
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
require('./polyfills');
|
||||
|
||||
var CONST = require('./const');
|
||||
var Extend = require('./utils/object/Extend');
|
||||
|
||||
/**
|
||||
* @namespace Phaser
|
||||
*/
|
||||
|
||||
var Phaser = {
|
||||
|
||||
Animation: require('./animations'),
|
||||
Cache: require('./cache'),
|
||||
Cameras: { Scene2D: require('./cameras/2d') },
|
||||
Class: require('./utils/Class'),
|
||||
Data: require('./data'),
|
||||
Display: { Masks: require('./display/mask') },
|
||||
EventEmitter: require('./events/EventEmitter'),
|
||||
Game: require('./boot/Game'),
|
||||
GameObjects: {
|
||||
DisplayList: require('./gameobjects/DisplayList'),
|
||||
GameObjectCreator: require('./gameobjects/GameObjectCreator'),
|
||||
GameObjectFactory: require('./gameobjects/GameObjectFactory'),
|
||||
UpdateList: require('./gameobjects/UpdateList'),
|
||||
Components: require('./gameobjects/components'),
|
||||
BuildGameObject: require('./gameobjects/BuildGameObject'),
|
||||
BuildGameObjectAnimation: require('./gameobjects/BuildGameObjectAnimation'),
|
||||
GameObject: require('./gameobjects/GameObject'),
|
||||
Graphics: require('./gameobjects/graphics/Graphics.js'),
|
||||
Image: require('./gameobjects/image/Image'),
|
||||
Sprite: require('./gameobjects/sprite/Sprite'),
|
||||
Text: require('./gameobjects/text/static/Text'),
|
||||
Factories: {
|
||||
Graphics: require('./gameobjects/graphics/GraphicsFactory'),
|
||||
Image: require('./gameobjects/image/ImageFactory'),
|
||||
Sprite: require('./gameobjects/sprite/SpriteFactory'),
|
||||
Text: require('./gameobjects/text/static/TextFactory')
|
||||
},
|
||||
Creators: {
|
||||
Graphics: require('./gameobjects/graphics/GraphicsCreator'),
|
||||
Image: require('./gameobjects/image/ImageCreator'),
|
||||
Sprite: require('./gameobjects/sprite/SpriteCreator'),
|
||||
Text: require('./gameobjects/text/static/TextCreator')
|
||||
}
|
||||
},
|
||||
Input: require('./input'),
|
||||
Loader: {
|
||||
FileTypes: {
|
||||
AnimationJSONFile: require('./loader/filetypes/AnimationJSONFile'),
|
||||
AtlasJSONFile: require('./loader/filetypes/AtlasJSONFile'),
|
||||
AudioFile: require('./loader/filetypes/AudioFile'),
|
||||
AudioSprite: require('./loader/filetypes/AudioSprite'),
|
||||
HTML5AudioFile: require('./loader/filetypes/HTML5AudioFile'),
|
||||
ImageFile: require('./loader/filetypes/ImageFile'),
|
||||
JSONFile: require('./loader/filetypes/JSONFile'),
|
||||
MultiAtlas: require('./loader/filetypes/MultiAtlas'),
|
||||
PluginFile: require('./loader/filetypes/PluginFile'),
|
||||
ScriptFile: require('./loader/filetypes/ScriptFile'),
|
||||
SpriteSheetFile: require('./loader/filetypes/SpriteSheetFile'),
|
||||
TextFile: require('./loader/filetypes/TextFile'),
|
||||
XMLFile: require('./loader/filetypes/XMLFile')
|
||||
}
|
||||
},
|
||||
Math: {
|
||||
Between: require('./math/Between'),
|
||||
DegToRad: require('./math/DegToRad'),
|
||||
FloatBetween: require('./math/FloatBetween'),
|
||||
RadToDeg: require('./math/RadToDeg'),
|
||||
Vector2: require('./math/Vector2')
|
||||
},
|
||||
Renderer: require('./renderer'),
|
||||
Scene: require('./scene/Scene'),
|
||||
Scenes: require('./scene'),
|
||||
Sound: require('./sound'),
|
||||
Structs: require('./structs'),
|
||||
Textures: require('./textures'),
|
||||
Time: require('./time'),
|
||||
Tweens: require('./tweens')
|
||||
};
|
||||
|
||||
// Merge in the consts
|
||||
|
||||
Phaser = Extend(false, Phaser, CONST);
|
||||
|
||||
// Export it
|
||||
|
||||
module.exports = Phaser;
|
||||
|
||||
global.Phaser = Phaser;
|
||||
|
||||
/*
|
||||
* "Documentation is like pizza: when it is good, it is very, very good;
|
||||
* and when it is bad, it is better than nothing."
|
||||
* -- Dick Brandon
|
||||
*/
|
|
@ -10,8 +10,8 @@ var CONST = require('./const');
|
|||
var Extend = require('./utils/object/Extend');
|
||||
|
||||
/**
|
||||
* @namespace Phaser
|
||||
*/
|
||||
* @namespace Phaser
|
||||
*/
|
||||
|
||||
var Phaser = {
|
||||
|
||||
|
|
|
@ -51,11 +51,6 @@ var ArcadePhysics = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -82,6 +77,30 @@ var ArcadePhysics = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.add;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
start: function ()
|
||||
{
|
||||
this.world = new World(this.scene, this.config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.on('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -105,25 +124,6 @@ var ArcadePhysics = new Class({
|
|||
return config;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
this.world = new World(this.scene, this.config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.on('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body.
|
||||
*
|
||||
|
@ -440,25 +440,43 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#shutdown
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('update', this.world.update, this.world);
|
||||
eventEmitter.off('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
|
||||
this.world.shutdown();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.add.destroy();
|
||||
this.world.destroy();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
this.world = null;
|
||||
this.add = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -245,6 +245,19 @@ var Factory = new Class({
|
|||
group: function (children, config)
|
||||
{
|
||||
return this.sys.updateList.add(new PhysicsGroup(this.world, this.world.scene, children, config));
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Factory.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Factory#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.world = null;
|
||||
this.scene = null;
|
||||
this.sys = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1833,6 +1833,12 @@ var World = new Class({
|
|||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.tree.clear();
|
||||
this.staticTree.clear();
|
||||
this.bodies.clear();
|
||||
this.staticBodies.clear();
|
||||
this.colliders.destroy();
|
||||
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
|
@ -1844,13 +1850,9 @@ var World = new Class({
|
|||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.tree.clear();
|
||||
this.staticTree.clear();
|
||||
this.bodies.clear();
|
||||
this.staticBodies.clear();
|
||||
this.colliders.destroy();
|
||||
this.shutdown();
|
||||
|
||||
this.removeAllListeners();
|
||||
this.scene = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -132,6 +132,18 @@ var Factory = new Class({
|
|||
this.sys.updateList.add(sprite);
|
||||
|
||||
return sprite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Factory.
|
||||
*
|
||||
* @method Phaser.Physics.Impact.Factory#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.world = null;
|
||||
this.sys = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -46,11 +46,6 @@ var ImpactPhysics = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -77,6 +72,29 @@ var ImpactPhysics = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.add;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Physics.Impact.ImpactPhysics#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
start: function ()
|
||||
{
|
||||
this.world = new World(this.scene, this.config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -100,24 +118,6 @@ var ImpactPhysics = new Class({
|
|||
return config;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Physics.Impact.ImpactPhysics#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
this.world = new World(this.scene, this.config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -145,25 +145,44 @@ var ImpactPhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Physics.Impact.ImpactPhysics#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.world.shutdown();
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('update', this.world.update, this.world);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Physics.Impact.ImpactPhysics#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.add.destroy();
|
||||
this.world.destroy();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
this.world = null;
|
||||
this.add = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -511,6 +511,13 @@ var Factory = new Class({
|
|||
*/
|
||||
pointerConstraint: function (options)
|
||||
{
|
||||
if (options === undefined) { options = {}; }
|
||||
|
||||
if (!options.hasOwnProperty('render'))
|
||||
{
|
||||
options.render = { visible: false };
|
||||
}
|
||||
|
||||
var pointerConstraint = new PointerConstraint(this.scene, this.world, options);
|
||||
|
||||
this.world.add(pointerConstraint.constraint);
|
||||
|
@ -597,6 +604,19 @@ var Factory = new Class({
|
|||
gameObject: function (gameObject, options)
|
||||
{
|
||||
return MatterGameObject(this.world, gameObject, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Factory.
|
||||
*
|
||||
* @method Phaser.Physics.Matter.Factory#destroy
|
||||
* @since 3.5.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.world = null;
|
||||
this.scene = null;
|
||||
this.sys = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -51,11 +51,6 @@ var MatterPhysics = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -82,6 +77,44 @@ var MatterPhysics = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.add;
|
||||
|
||||
// Matter plugins
|
||||
|
||||
if (GetValue(this.config, 'plugins.attractors', false))
|
||||
{
|
||||
Plugin.register(MatterAttractors);
|
||||
Plugin.use(MatterLib, MatterAttractors);
|
||||
}
|
||||
|
||||
if (GetValue(this.config, 'plugins.wrap', false))
|
||||
{
|
||||
Plugin.register(MatterWrap);
|
||||
Plugin.use(MatterLib, MatterWrap);
|
||||
}
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Physics.Matter.MatterPhysics#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
start: function ()
|
||||
{
|
||||
this.world = new World(this.scene, this.config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.on('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -105,41 +138,6 @@ var MatterPhysics = new Class({
|
|||
return config;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Physics.Matter.MatterPhysics#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var config = this.config;
|
||||
|
||||
this.world = new World(this.scene, config);
|
||||
this.add = new Factory(this.world);
|
||||
|
||||
// Matter plugins
|
||||
|
||||
if (GetValue(config, 'plugins.attractors', false))
|
||||
{
|
||||
Plugin.register(MatterAttractors);
|
||||
Plugin.use(MatterLib, MatterAttractors);
|
||||
}
|
||||
|
||||
if (GetValue(config, 'plugins.wrap', false))
|
||||
{
|
||||
Plugin.register(MatterWrap);
|
||||
Plugin.use(MatterLib, MatterWrap);
|
||||
}
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('update', this.world.update, this.world);
|
||||
eventEmitter.on('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -265,25 +263,45 @@ var MatterPhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Physics.Matter.MatterPhysics#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.world.shutdown();
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('update', this.world.update, this.world);
|
||||
eventEmitter.off('postupdate', this.world.postUpdate, this.world);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Physics.Matter.MatterPhysics#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.add.destroy();
|
||||
this.world.destroy();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
this.world = null;
|
||||
this.add = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -232,21 +232,16 @@ var World = new Class({
|
|||
|
||||
MatterEvents.on(engine, 'beforeUpdate', function (event)
|
||||
{
|
||||
|
||||
_this.emit('beforeupdate', event);
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(engine, 'afterUpdate', function (event)
|
||||
{
|
||||
|
||||
_this.emit('afterupdate', event);
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(engine, 'collisionStart', function (event)
|
||||
{
|
||||
|
||||
var pairs = event.pairs;
|
||||
var bodyA;
|
||||
var bodyB;
|
||||
|
@ -258,12 +253,10 @@ var World = new Class({
|
|||
}
|
||||
|
||||
_this.emit('collisionstart', event, bodyA, bodyB);
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(engine, 'collisionActive', function (event)
|
||||
{
|
||||
|
||||
var pairs = event.pairs;
|
||||
var bodyA;
|
||||
var bodyB;
|
||||
|
@ -275,12 +268,10 @@ var World = new Class({
|
|||
}
|
||||
|
||||
_this.emit('collisionactive', event, bodyA, bodyB);
|
||||
|
||||
});
|
||||
|
||||
MatterEvents.on(engine, 'collisionEnd', function (event)
|
||||
{
|
||||
|
||||
var pairs = event.pairs;
|
||||
var bodyA;
|
||||
var bodyB;
|
||||
|
@ -292,7 +283,6 @@ var World = new Class({
|
|||
}
|
||||
|
||||
_this.emit('collisionend', event, bodyA, bodyB);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -894,7 +884,7 @@ var World = new Class({
|
|||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
MatterEvents.off();
|
||||
MatterEvents.off(this.engine);
|
||||
|
||||
this.removeAllListeners();
|
||||
|
||||
|
|
|
@ -443,19 +443,8 @@ var CanvasRenderer = new Class({
|
|||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
|
||||
if (camera._fadeAlpha > 0)
|
||||
{
|
||||
// fade rendering
|
||||
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 = 'rgba(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ',' + camera._flashAlpha + ')';
|
||||
ctx.fillRect(camera.x, camera.y, camera.width, camera.height);
|
||||
}
|
||||
camera.flashEffect.postRenderCanvas(ctx);
|
||||
camera.fadeEffect.postRenderCanvas(ctx);
|
||||
|
||||
// Reset the camera scissor
|
||||
if (scissor)
|
||||
|
|
|
@ -1402,30 +1402,13 @@ var WebGLRenderer = new Class({
|
|||
*/
|
||||
postRenderCamera: function (camera)
|
||||
{
|
||||
if (camera._fadeAlpha > 0 || camera._flashAlpha > 0)
|
||||
var FlatTintPipeline = this.pipelines.FlatTintPipeline;
|
||||
|
||||
var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats);
|
||||
var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats);
|
||||
|
||||
if (isFading || isFlashing)
|
||||
{
|
||||
var FlatTintPipeline = this.pipelines.FlatTintPipeline;
|
||||
|
||||
// Fade
|
||||
FlatTintPipeline.batchFillRect(
|
||||
0, 0, 1, 1, 0,
|
||||
camera.x, camera.y, camera.width, camera.height,
|
||||
Utils.getTintFromFloats(camera._fadeRed, camera._fadeGreen, camera._fadeBlue, 1.0),
|
||||
camera._fadeAlpha,
|
||||
1, 0, 0, 1, 0, 0,
|
||||
[ 1, 0, 0, 1, 0, 0 ]
|
||||
);
|
||||
|
||||
// Flash
|
||||
FlatTintPipeline.batchFillRect(
|
||||
0, 0, 1, 1, 0,
|
||||
camera.x, camera.y, camera.width, camera.height,
|
||||
Utils.getTintFromFloats(camera._flashRed, camera._flashGreen, camera._flashBlue, 1.0),
|
||||
camera._flashAlpha,
|
||||
1, 0, 0, 1, 0, 0,
|
||||
[ 1, 0, 0, 1, 0, 0 ]
|
||||
);
|
||||
|
||||
FlatTintPipeline.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -139,10 +139,9 @@ var SceneManager = new Class({
|
|||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// Only need to wait for the boot event if we've scenes to actually boot
|
||||
game.events.once('ready', this.bootQueue, this);
|
||||
}
|
||||
|
||||
game.events.once('ready', this.bootQueue, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -393,7 +392,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
var sceneToRemove = this.getScene(key);
|
||||
|
||||
if (!sceneToRemove)
|
||||
if (!sceneToRemove || sceneToRemove.sys.isTransitioning())
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
@ -430,16 +429,24 @@ var SceneManager = new Class({
|
|||
*/
|
||||
bootScene: function (scene)
|
||||
{
|
||||
var sys = scene.sys;
|
||||
var settings = sys.settings;
|
||||
|
||||
if (scene.init)
|
||||
{
|
||||
scene.init.call(scene, scene.sys.settings.data);
|
||||
scene.init.call(scene, settings.data);
|
||||
|
||||
if (settings.isTransition)
|
||||
{
|
||||
sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration);
|
||||
}
|
||||
}
|
||||
|
||||
var loader;
|
||||
|
||||
if (scene.sys.load)
|
||||
if (sys.load)
|
||||
{
|
||||
loader = scene.sys.load;
|
||||
loader = sys.load;
|
||||
|
||||
loader.reset();
|
||||
}
|
||||
|
@ -455,7 +462,7 @@ var SceneManager = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
scene.sys.settings.status = CONST.LOADING;
|
||||
settings.status = CONST.LOADING;
|
||||
|
||||
// Start the loader going as we have something in the queue
|
||||
loader.once('complete', this.loadComplete, this);
|
||||
|
@ -485,6 +492,12 @@ var SceneManager = new Class({
|
|||
{
|
||||
var scene = loader.scene;
|
||||
|
||||
// Try to unlock HTML5 sounds every time any loader completes
|
||||
if (this.game.sound.onBlurPausedSounds)
|
||||
{
|
||||
this.game.sound.unlock();
|
||||
}
|
||||
|
||||
this.create(scene);
|
||||
},
|
||||
|
||||
|
@ -584,14 +597,22 @@ var SceneManager = new Class({
|
|||
*/
|
||||
create: function (scene)
|
||||
{
|
||||
var sys = scene.sys;
|
||||
var settings = sys.settings;
|
||||
|
||||
if (scene.create)
|
||||
{
|
||||
scene.sys.settings.status = CONST.CREATING;
|
||||
|
||||
scene.create.call(scene, scene.sys.settings.data);
|
||||
|
||||
if (settings.isTransition)
|
||||
{
|
||||
sys.events.emit('transitionstart', settings.transitionFrom, settings.transitionDuration);
|
||||
}
|
||||
}
|
||||
|
||||
scene.sys.settings.status = CONST.RUNNING;
|
||||
settings.status = CONST.RUNNING;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -817,6 +838,10 @@ var SceneManager = new Class({
|
|||
return this.keys[key];
|
||||
}
|
||||
}
|
||||
|
||||
// What's the point? If you already have the Scene to pass in to this function, you have the Scene!
|
||||
|
||||
/*
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < this.scenes.length; i++)
|
||||
|
@ -827,6 +852,7 @@ var SceneManager = new Class({
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return null;
|
||||
},
|
||||
|
@ -955,7 +981,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
var scene = this.getScene(key);
|
||||
|
||||
if (scene)
|
||||
if (scene && !scene.sys.isTransitioning())
|
||||
{
|
||||
scene.sys.sleep();
|
||||
}
|
||||
|
@ -1059,7 +1085,7 @@ var SceneManager = new Class({
|
|||
{
|
||||
var scene = this.getScene(key);
|
||||
|
||||
if (scene)
|
||||
if (scene && !scene.sys.isTransitioning())
|
||||
{
|
||||
scene.sys.shutdown();
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Clamp = require('../math/Clamp');
|
||||
var Class = require('../utils/Class');
|
||||
var CONST = require('./const');
|
||||
var GetFastValue = require('../utils/object/GetFastValue');
|
||||
var PluginManager = require('../boot/PluginManager');
|
||||
|
||||
/**
|
||||
|
@ -43,11 +45,6 @@ var ScenePlugin = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings of the Scene this ScenePlugin belongs to.
|
||||
*
|
||||
|
@ -74,22 +71,107 @@ var ScenePlugin = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.manager = scene.sys.game.scene;
|
||||
|
||||
/**
|
||||
* If this Scene is currently transitioning to another, this holds
|
||||
* the current percentage of the transition progress, between 0 and 1.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#transitionProgress
|
||||
* @type {float}
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this.transitionProgress = 0;
|
||||
|
||||
/**
|
||||
* Transition elapsed timer.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_elapsed
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._elapsed = 0;
|
||||
|
||||
/**
|
||||
* Transition elapsed timer.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_target
|
||||
* @type {?Phaser.Scenes.Scene}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._target = null;
|
||||
|
||||
/**
|
||||
* Transition duration.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_duration
|
||||
* @type {integer}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._duration = 0;
|
||||
|
||||
/**
|
||||
* Transition callback.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_onUpdate
|
||||
* @type {function}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdate;
|
||||
|
||||
/**
|
||||
* Transition callback scope.
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_onUpdateScope
|
||||
* @type {object}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._onUpdateScope;
|
||||
|
||||
/**
|
||||
* Will this Scene sleep (true) after the transition, or stop (false)
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_willSleep
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._willSleep = false;
|
||||
|
||||
/**
|
||||
* Will this Scene be removed from the Scene Manager after the transition completes?
|
||||
*
|
||||
* @name Phaser.Scenes.ScenePlugin#_willRemove
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
this._willRemove = false;
|
||||
|
||||
scene.sys.events.on('start', this.pluginStart, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Boot the ScenePlugin.
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* Registers event handlers.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#boot
|
||||
* @method Phaser.Scenes.ScenePlugin#pluginStart
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
pluginStart: function ()
|
||||
{
|
||||
this._target = null;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -149,6 +231,215 @@ var ScenePlugin = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* @typedef {object} Phaser.Scenes.ScenePlugin#SceneTransitionConfig
|
||||
*
|
||||
* @property {string} target - The Scene key to transition to.
|
||||
* @property {integer} [duration=1000] - The duration, in ms, for the transition to last.
|
||||
* @property {boolean} [sleep=false] - Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`)
|
||||
* @property {boolean} [allowInput=false] - Will the Scenes Input system be able to process events while it is transitioning in or out?
|
||||
* @property {boolean} [moveAbove] - More the target Scene to be above this one before the transition starts.
|
||||
* @property {boolean} [moveBelow] - More the target Scene to be below this one before the transition starts.
|
||||
* @property {function} [onUpdate] - This callback is invoked every frame for the duration of the transition.
|
||||
* @property {any} [onUpdateScope] - The context in which the callback is invoked.
|
||||
* @property {any} [data] - An object containing any data you wish to be passed to the target Scenes init / create methods.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This will start a transition from the current Scene to the target Scene given.
|
||||
*
|
||||
* The transition will last for the duration specified in milliseconds.
|
||||
*
|
||||
* You can have the target Scene moved above or below this one in the display list.
|
||||
*
|
||||
* You can specify an update callback. This callback will be invoked _every frame_ for the duration
|
||||
* of the transition.
|
||||
*
|
||||
* This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop.
|
||||
*
|
||||
* There are also 5 transition related events: This scene will emit the event `transitionto` when
|
||||
* the transition begins, which is typically the frame after calling this method.
|
||||
*
|
||||
* The target Scene will emit the event `transitioninit` when that Scene's `init` method is called.
|
||||
* It will then emit the event `transitionstart` when its `create` method is called.
|
||||
* If the Scene was sleeping and has been woken up, it will emit the event `transitionwake` instead of these two,
|
||||
* as the Scenes `init` and `create` methods are not invoked when a sleep wakes up.
|
||||
*
|
||||
* When the duration of the transition has elapsed it will emit the event `transitioncomplete`.
|
||||
* These events are all cleared of listeners when the Scene shuts down, but not if it is sent to sleep.
|
||||
*
|
||||
* It's important to understand that the duration of the transition begins the moment you call this method.
|
||||
* If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the
|
||||
* time still counts down even while that is happening. If the game itself pauses, or something else causes
|
||||
* this Scenes update loop to stop, then the transition will also pause for that duration. There are
|
||||
* checks in place to prevent you accidentally stopping a transitioning Scene but if you've got code to
|
||||
* override this understand that until the target Scene completes it might never be unlocked for input events.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#transition
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Scenes.ScenePlugin#SceneTransitionConfig} config - The transition configuration object.
|
||||
*
|
||||
* @return {boolean} `true` is the transition was started, otherwise `false`.
|
||||
*/
|
||||
transition: function (config)
|
||||
{
|
||||
if (config === undefined) { config = {}; }
|
||||
|
||||
var key = GetFastValue(config, 'target', false);
|
||||
|
||||
var target = this.manager.getScene(key);
|
||||
|
||||
if (!key || !this.checkValidTransition(target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var duration = GetFastValue(config, 'duration', 1000);
|
||||
|
||||
this._elapsed = 0;
|
||||
this._target = target;
|
||||
this._duration = duration;
|
||||
this._willSleep = GetFastValue(config, 'sleep', false);
|
||||
this._willRemove = GetFastValue(config, 'remove', false);
|
||||
|
||||
var callback = GetFastValue(config, 'onUpdate', null);
|
||||
|
||||
if (callback)
|
||||
{
|
||||
this._onUpdate = callback;
|
||||
this._onUpdateScope = GetFastValue(config, 'onUpdateScope', this.scene);
|
||||
}
|
||||
|
||||
var allowInput = GetFastValue(config, 'allowInput', false);
|
||||
|
||||
this.settings.transitionAllowInput = allowInput;
|
||||
|
||||
var targetSettings = target.sys.settings;
|
||||
|
||||
targetSettings.isTransition = true;
|
||||
targetSettings.transitionFrom = this.scene;
|
||||
targetSettings.transitionDuration = duration;
|
||||
targetSettings.transitionAllowInput = allowInput;
|
||||
|
||||
if (GetFastValue(config, 'moveAbove', false))
|
||||
{
|
||||
this.manager.moveAbove(this.key, key);
|
||||
}
|
||||
else if (GetFastValue(config, 'moveBelow', false))
|
||||
{
|
||||
this.manager.moveBelow(this.key, key);
|
||||
}
|
||||
|
||||
if (target.sys.isSleeping())
|
||||
{
|
||||
target.sys.wake();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.manager.start(key);
|
||||
}
|
||||
|
||||
this.systems.events.emit('transitionout', target, duration);
|
||||
|
||||
this.systems.events.on('update', this.step, this);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if this Scene can transition to the target Scene or not.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#checkValidTransition
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Phaser.Scene} target - The Scene to test against.
|
||||
*
|
||||
* @return {boolean} `true` if this Scene can transition, otherwise `false`.
|
||||
*/
|
||||
checkValidTransition: function (target)
|
||||
{
|
||||
// Not a valid target if it doesn't exist, isn't active or is already transitioning in or out
|
||||
if (!target || target.sys.isActive() || target.sys.isTransitioning() || target === this.scene || this.systems.isTransitioning())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* A single game step. This is only called if the parent Scene is transitioning
|
||||
* out to another Scene.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#step
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
*/
|
||||
step: function (time, delta)
|
||||
{
|
||||
this._elapsed += delta;
|
||||
|
||||
this.transitionProgress = Clamp(this._elapsed / this._duration, 0, 1);
|
||||
|
||||
if (this._onUpdate)
|
||||
{
|
||||
this._onUpdate.call(this._onUpdateScope, this.transitionProgress);
|
||||
}
|
||||
|
||||
if (this._elapsed >= this._duration)
|
||||
{
|
||||
this.transitionComplete();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by `step` when the transition out of this scene to another is over.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#transitionComplete
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
transitionComplete: function ()
|
||||
{
|
||||
var targetSys = this._target.sys;
|
||||
var targetSettings = this._target.sys.settings;
|
||||
|
||||
// Stop the step
|
||||
this.systems.events.off('update', this.step, this);
|
||||
|
||||
// Notify target scene
|
||||
targetSys.events.emit('transitioncomplete', this.scene);
|
||||
|
||||
// Clear target scene settings
|
||||
targetSettings.isTransition = false;
|
||||
targetSettings.transitionFrom = null;
|
||||
|
||||
// Clear local settings
|
||||
this._duration = 0;
|
||||
this._target = null;
|
||||
this._onUpdate = null;
|
||||
this._onUpdateScope = null;
|
||||
|
||||
// Now everything is clear we can handle what happens to this Scene
|
||||
if (this._willRemove)
|
||||
{
|
||||
this.manager.remove(this.key);
|
||||
}
|
||||
else if (this._willSleep)
|
||||
{
|
||||
this.systems.sleep();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.manager.stop(this.key);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set.
|
||||
*
|
||||
|
@ -599,25 +890,40 @@ var ScenePlugin = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Shut down the given Scene.
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
// TODO
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
eventEmitter.off('postupdate', this.step, this);
|
||||
eventEmitter.off('transitionout');
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the given Scene.
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Scenes.ScenePlugin#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
// TODO
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
this.settings = null;
|
||||
this.manager = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -34,6 +34,10 @@ var InjectionMap = require('./InjectionMap');
|
|||
* @property {boolean} active - [description]
|
||||
* @property {boolean} visible - [description]
|
||||
* @property {boolean} isBooted - [description]
|
||||
* @property {boolean} isTransition - [description]
|
||||
* @property {?Phaser.Scene} transitionFrom - [description]
|
||||
* @property {integer} transitionDuration - [description]
|
||||
* @property {boolean} transitionAllowInput - [description]
|
||||
* @property {object} data - [description]
|
||||
* @property {(false|LoaderFileObject[])} files - [description]
|
||||
* @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description]
|
||||
|
@ -77,6 +81,11 @@ var Settings = {
|
|||
|
||||
isBooted: false,
|
||||
|
||||
isTransition: false,
|
||||
transitionFrom: null,
|
||||
transitionDuration: 0,
|
||||
transitionAllowInput: true,
|
||||
|
||||
// Loader payload array
|
||||
|
||||
data: {},
|
||||
|
|
|
@ -210,12 +210,15 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called only once by the Scene Manager when the Scene is instantiated.
|
||||
* It is responsible for setting up all of the Scene plugins and references.
|
||||
* It should never be called directly.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#init
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Game} game - A reference to the Phaser Game
|
||||
* @param {Phaser.Game} game - A reference to the Phaser Game instance.
|
||||
*/
|
||||
init: function (game)
|
||||
{
|
||||
|
@ -244,7 +247,7 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called by a plugin, it tells the System to install the plugin locally.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#install
|
||||
* @private
|
||||
|
@ -263,7 +266,8 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A single game step. Called automatically by the Scene Manager as a result of a Request Animation
|
||||
* Frame or Set Timeout call to the main Game instance.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#step
|
||||
* @since 3.0.0
|
||||
|
@ -283,7 +287,8 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by the Scene Manager. Instructs the Scene to render itself via
|
||||
* its Camera Manager to the renderer given.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#render
|
||||
* @since 3.0.0
|
||||
|
@ -347,7 +352,7 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Resume this Scene.
|
||||
* Resume this Scene from a paused state.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#resume
|
||||
* @since 3.0.0
|
||||
|
@ -371,8 +376,10 @@ var Systems = new Class({
|
|||
/**
|
||||
* Send this Scene to sleep.
|
||||
*
|
||||
* A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed,
|
||||
* or have any of its systems or children removed, meaning it can be re-activated at any point.
|
||||
* A sleeping Scene doesn't run it's update step or render anything, but it also isn't shut down
|
||||
* or have any of its systems or children removed, meaning it can be re-activated at any point and
|
||||
* will carry on from where it left off. It also keeps everything in memory and events and callbacks
|
||||
* from other Scenes may still invoke changes within it, so be careful what is left active.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#sleep
|
||||
* @since 3.0.0
|
||||
|
@ -401,13 +408,20 @@ var Systems = new Class({
|
|||
*/
|
||||
wake: function ()
|
||||
{
|
||||
this.settings.status = CONST.RUNNING;
|
||||
var settings = this.settings;
|
||||
|
||||
this.settings.active = true;
|
||||
this.settings.visible = true;
|
||||
settings.status = CONST.RUNNING;
|
||||
|
||||
settings.active = true;
|
||||
settings.visible = true;
|
||||
|
||||
this.events.emit('wake', this);
|
||||
|
||||
if (settings.isTransition)
|
||||
{
|
||||
this.events.emit('transitionwake', settings.transitionFrom, settings.transitionDuration);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -437,6 +451,45 @@ var Systems = new Class({
|
|||
return (this.settings.status === CONST.RUNNING);
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this Scene currently transitioning out to, or in from another Scene?
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#isTransitioning
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @return {boolean} `true` if this Scene is currently transitioning, otherwise `false`.
|
||||
*/
|
||||
isTransitioning: function ()
|
||||
{
|
||||
return (this.settings.isTransition || this.scenePlugin._target !== null);
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this Scene currently transitioning out from itself to another Scene?
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#isTransitionOut
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @return {boolean} `true` if this Scene is in transition to another Scene, otherwise `false`.
|
||||
*/
|
||||
isTransitionOut: function ()
|
||||
{
|
||||
return (this.scenePlugin._target !== null && this.scenePlugin._duration > 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this Scene currently transitioning in from another Scene?
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#isTransitionIn
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @return {boolean} `true` if this Scene is transitioning in from another Scene, otherwise `false`.
|
||||
*/
|
||||
isTransitionIn: function ()
|
||||
{
|
||||
return (this.settings.isTransition);
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this Scene visible and rendering?
|
||||
*
|
||||
|
@ -451,7 +504,8 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the visible state of this Scene.
|
||||
* An invisible Scene will not render, but will still process updates.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#setVisible
|
||||
* @since 3.0.0
|
||||
|
@ -468,12 +522,13 @@ var Systems = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Set the active state of this Scene.
|
||||
* An active Scene will run its core update loop.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#setActive
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} value - [description]
|
||||
* @param {boolean} value - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused.
|
||||
*
|
||||
* @return {Phaser.Scenes.Systems} This Systems object.
|
||||
*/
|
||||
|
@ -496,7 +551,7 @@ var Systems = new Class({
|
|||
* @method Phaser.Scenes.Systems#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} data - [description]
|
||||
* @param {object} data - Optional data object that may have been passed to this Scene from another.
|
||||
*/
|
||||
start: function (data)
|
||||
{
|
||||
|
@ -530,12 +585,21 @@ var Systems = new Class({
|
|||
|
||||
/**
|
||||
* Shutdown this Scene and send a shutdown event to all of its systems.
|
||||
* A Scene that has been shutdown will not run its update loop or render, but it does
|
||||
* not destroy any of its plugins or references. It is put into hibernation for later use.
|
||||
* If you don't ever plan to use this Scene again, then it should be destroyed instead
|
||||
* to free-up resources.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#shutdown
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
this.events.off('transitioninit');
|
||||
this.events.off('transitionstart');
|
||||
this.events.off('transitioncomplete');
|
||||
this.events.off('transitionout');
|
||||
|
||||
this.settings.status = CONST.SHUTDOWN;
|
||||
|
||||
this.settings.active = false;
|
||||
|
@ -546,8 +610,11 @@ var Systems = new Class({
|
|||
|
||||
/**
|
||||
* Destroy this Scene and send a destroy event all of its systems.
|
||||
* A destroyed Scene cannot be restarted.
|
||||
* You should not call this directly, instead use `SceneManager.remove`.
|
||||
*
|
||||
* @method Phaser.Scenes.Systems#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
|
@ -558,6 +625,15 @@ var Systems = new Class({
|
|||
this.settings.visible = false;
|
||||
|
||||
this.events.emit('destroy', this);
|
||||
|
||||
this.events.removeAllListeners();
|
||||
|
||||
var props = [ 'scene', 'game', 'anims', 'cache', 'plugins', 'registry', 'sound', 'textures', 'add', 'camera', 'displayList', 'events', 'make', 'scenePlugin', 'updateList' ];
|
||||
|
||||
for (var i = 0; i < props.length; i++)
|
||||
{
|
||||
this[props[i]] = null;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -144,51 +144,6 @@ var BaseSound = new Class({
|
|||
|
||||
this.config = Extend(this.config, config);
|
||||
|
||||
/**
|
||||
* Boolean indicating whether the sound is muted or not.
|
||||
* Gets or sets the muted state of this sound.
|
||||
*
|
||||
* @name Phaser.Sound.BaseSound#mute
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.mute = false;
|
||||
|
||||
/**
|
||||
* Gets or sets the volume of this sound,
|
||||
* a value between 0 (silence) and 1 (full volume).
|
||||
*
|
||||
* @name Phaser.Sound.BaseSound#volume
|
||||
* @type {number}
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.volume = 1;
|
||||
|
||||
/**
|
||||
* Property representing the position of playback for this sound, in seconds.
|
||||
* Setting it to a specific value moves current playback to that position.
|
||||
* The value given is clamped to the range 0 to current marker duration.
|
||||
* Setting seek of a stopped sound has no effect.
|
||||
*
|
||||
* @name Phaser.Sound.BaseSound#seek
|
||||
* @type {number}
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.seek = 0;
|
||||
|
||||
/**
|
||||
* Flag indicating whether or not the sound or current sound marker will loop.
|
||||
*
|
||||
* @name Phaser.Sound.BaseSound#loop
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.loop = false;
|
||||
|
||||
/**
|
||||
* Object containing markers definitions.
|
||||
*
|
||||
|
@ -290,7 +245,7 @@ var BaseSound = new Class({
|
|||
if (!this.markers[marker.name])
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!');
|
||||
console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -349,9 +304,6 @@ var BaseSound = new Class({
|
|||
|
||||
if (typeof markerName !== 'string')
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Sound marker name has to be a string!');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -366,7 +318,7 @@ var BaseSound = new Class({
|
|||
if (!this.markers[markerName])
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!');
|
||||
console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ var NOOP = require('../utils/NOOP');
|
|||
* @classdesc
|
||||
* The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback.
|
||||
* The audio file type and the encoding of those files are extremely important.
|
||||
*
|
||||
*
|
||||
* Not all browsers can play all audio formats.
|
||||
*
|
||||
*
|
||||
* There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support).
|
||||
*
|
||||
* @class BaseSoundManager
|
||||
|
@ -169,11 +169,6 @@ var BaseSoundManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this.unlocked = false;
|
||||
|
||||
if (this.locked)
|
||||
{
|
||||
this.unlock();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -537,7 +532,7 @@ var BaseSoundManager = new Class({
|
|||
|
||||
/**
|
||||
* Sets the global playback rate at which all the sounds will be played.
|
||||
*
|
||||
*
|
||||
* For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed
|
||||
* and 2.0 doubles the audios playback speed.
|
||||
*
|
||||
|
|
|
@ -47,7 +47,7 @@ var HTML5AudioSound = new Class({
|
|||
if (!this.tags)
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('No audio loaded in cache with key: \'' + key + '\'!');
|
||||
console.warn('Audio cache entry missing: ' + key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ var HTML5AudioSound = new Class({
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BaseSound.prototype.play.call(this, markerName, config))
|
||||
{
|
||||
return false;
|
||||
|
@ -610,7 +611,8 @@ var HTML5AudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Boolean indicating whether the sound is muted or not.
|
||||
* Gets or sets the muted state of this sound.
|
||||
*
|
||||
* @name Phaser.Sound.HTML5AudioSound#mute
|
||||
* @type {boolean}
|
||||
|
@ -633,8 +635,6 @@ var HTML5AudioSound = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
this.setMute();
|
||||
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
},
|
||||
|
@ -664,7 +664,7 @@ var HTML5AudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume).
|
||||
*
|
||||
* @name Phaser.Sound.HTML5AudioSound#volume
|
||||
* @type {number}
|
||||
|
@ -687,8 +687,6 @@ var HTML5AudioSound = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
this.setVolume();
|
||||
|
||||
this.emit('volume', this, value);
|
||||
}
|
||||
},
|
||||
|
@ -839,7 +837,10 @@ var HTML5AudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Property representing the position of playback for this sound, in seconds.
|
||||
* Setting it to a specific value moves current playback to that position.
|
||||
* The value given is clamped to the range 0 to current marker duration.
|
||||
* Setting seek of a stopped sound has no effect.
|
||||
*
|
||||
* @name Phaser.Sound.HTML5AudioSound#seek
|
||||
* @type {number}
|
||||
|
@ -919,7 +920,7 @@ var HTML5AudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Flag indicating whether or not the sound or current sound marker will loop.
|
||||
*
|
||||
* @name Phaser.Sound.HTML5AudioSound#loop
|
||||
* @type {boolean}
|
||||
|
|
|
@ -96,7 +96,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.lockedActionsQueue = this.locked ? [] : null;
|
||||
this.lockedActionsQueue = null;
|
||||
|
||||
/**
|
||||
* Property that actually holds the value of global mute
|
||||
|
@ -154,6 +154,17 @@ var HTML5AudioSoundManager = new Class({
|
|||
*/
|
||||
unlock: function ()
|
||||
{
|
||||
this.locked = 'ontouchstart' in window;
|
||||
|
||||
if(this.locked)
|
||||
{
|
||||
this.lockedActionsQueue = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
|
||||
var moved = false;
|
||||
|
@ -165,11 +176,6 @@ var HTML5AudioSoundManager = new Class({
|
|||
|
||||
var unlock = function ()
|
||||
{
|
||||
if (!_this.game.cache.audio.entries.size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (moved)
|
||||
{
|
||||
moved = false;
|
||||
|
@ -179,26 +185,43 @@ var HTML5AudioSoundManager = new Class({
|
|||
document.body.removeEventListener('touchmove', detectMove);
|
||||
document.body.removeEventListener('touchend', unlock);
|
||||
|
||||
var allTags = [];
|
||||
var lockedTags = [];
|
||||
|
||||
_this.game.cache.audio.entries.each(function (key, tags)
|
||||
{
|
||||
for (var i = 0; i < tags.length; i++)
|
||||
{
|
||||
allTags.push(tags[i]);
|
||||
var tag = tags[i];
|
||||
|
||||
if (tag.dataset.locked === 'true')
|
||||
{
|
||||
lockedTags.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
var lastTag = allTags[allTags.length - 1];
|
||||
if (lockedTags.length === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lastTag = lockedTags[lockedTags.length - 1];
|
||||
|
||||
lastTag.oncanplaythrough = function ()
|
||||
{
|
||||
lastTag.oncanplaythrough = null;
|
||||
|
||||
lockedTags.forEach(function (tag)
|
||||
{
|
||||
tag.dataset.locked = 'false';
|
||||
});
|
||||
|
||||
_this.unlocked = true;
|
||||
};
|
||||
|
||||
allTags.forEach(function (tag)
|
||||
lockedTags.forEach(function (tag)
|
||||
{
|
||||
tag.load();
|
||||
});
|
||||
|
@ -208,7 +231,11 @@ var HTML5AudioSoundManager = new Class({
|
|||
{
|
||||
this.forEachActiveSound(function (sound)
|
||||
{
|
||||
sound.duration = sound.tags[0].duration;
|
||||
if(sound.currentMarker === null && sound.duration === 0)
|
||||
{
|
||||
sound.duration = sound.tags[0].duration;
|
||||
}
|
||||
|
||||
sound.totalDuration = sound.tags[0].duration;
|
||||
});
|
||||
|
||||
|
@ -226,6 +253,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
|
||||
this.lockedActionsQueue.length = 0;
|
||||
this.lockedActionsQueue = null;
|
||||
|
||||
}, this);
|
||||
|
||||
document.body.addEventListener('touchmove', detectMove, false);
|
||||
|
@ -302,7 +330,7 @@ var HTML5AudioSoundManager = new Class({
|
|||
*/
|
||||
isLocked: function (sound, prop, value)
|
||||
{
|
||||
if (this.locked)
|
||||
if (sound.tags[0].dataset.locked === 'true')
|
||||
{
|
||||
this.lockedActionsQueue.push({
|
||||
sound: sound,
|
||||
|
|
|
@ -45,7 +45,7 @@ var WebAudioSound = new Class({
|
|||
if (!this.audioBuffer)
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('No audio loaded in cache with key: \'' + key + '\'!');
|
||||
console.warn('Audio cache entry missing: ' + key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,8 @@ var WebAudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Boolean indicating whether the sound is muted or not.
|
||||
* Gets or sets the muted state of this sound.
|
||||
*
|
||||
* @name Phaser.Sound.WebAudioSound#mute
|
||||
* @type {boolean}
|
||||
|
@ -776,7 +777,7 @@ var WebAudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume).
|
||||
*
|
||||
* @name Phaser.Sound.WebAudioSound#volume
|
||||
* @type {number}
|
||||
|
@ -824,7 +825,10 @@ var WebAudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Property representing the position of playback for this sound, in seconds.
|
||||
* Setting it to a specific value moves current playback to that position.
|
||||
* The value given is clamped to the range 0 to current marker duration.
|
||||
* Setting seek of a stopped sound has no effect.
|
||||
*
|
||||
* @name Phaser.Sound.WebAudioSound#seek
|
||||
* @type {number}
|
||||
|
@ -902,7 +906,7 @@ var WebAudioSound = new Class({
|
|||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Flag indicating whether or not the sound or current sound marker will loop.
|
||||
*
|
||||
* @name Phaser.Sound.WebAudioSound#loop
|
||||
* @type {boolean}
|
||||
|
|
|
@ -76,6 +76,11 @@ var WebAudioSoundManager = new Class({
|
|||
this.locked = this.context.state === 'suspended' && 'ontouchstart' in window;
|
||||
|
||||
BaseSoundManager.call(this, game);
|
||||
|
||||
if (this.locked)
|
||||
{
|
||||
this.unlock();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -145,6 +150,7 @@ var WebAudioSoundManager = new Class({
|
|||
{
|
||||
document.body.removeEventListener('touchstart', unlock);
|
||||
document.body.removeEventListener('touchend', unlock);
|
||||
|
||||
_this.unlocked = true;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -668,6 +668,8 @@ var List = new Class({
|
|||
shutdown: function ()
|
||||
{
|
||||
this.removeAll();
|
||||
|
||||
this.list = [];
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -680,9 +682,9 @@ var List = new Class({
|
|||
{
|
||||
this.removeAll();
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.parent = null;
|
||||
this.addCallback = null;
|
||||
this.removeCallback = null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,11 +43,6 @@ var Clock = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -112,22 +107,27 @@ var Clock = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this._pendingRemoval = [];
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Time.Clock#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Time.Clock#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('preupdate', this.preUpdate, this);
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -313,9 +313,11 @@ var Clock = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Time.Clock#shutdown
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
|
@ -340,19 +342,30 @@ var Clock = new Class({
|
|||
this._active.length = 0;
|
||||
this._pendingRemoval.length = 0;
|
||||
this._pendingInsertion.length = 0;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('preupdate', this.preUpdate, this);
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Time.Clock#destroy
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene = undefined;
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -11,8 +11,6 @@ var TimelineBuilder = require('./builders/TimelineBuilder');
|
|||
var TWEEN_CONST = require('./tween/const');
|
||||
var TweenBuilder = require('./builders/TweenBuilder');
|
||||
|
||||
// Phaser.Tweens.TweenManager
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
|
@ -48,11 +46,6 @@ var TweenManager = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
{
|
||||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -113,22 +106,27 @@ var TweenManager = new Class({
|
|||
* @since 3.0.0
|
||||
*/
|
||||
this._toProcess = 0;
|
||||
|
||||
scene.sys.events.on('start', this.start, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* This method is called automatically by the Scene when it is starting up.
|
||||
* It is responsible for creating local systems, properties and listening for Scene events.
|
||||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Tweens.TweenManager#boot
|
||||
* @since 3.0.0
|
||||
* @method Phaser.Tweens.TweenManager#start
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
boot: function ()
|
||||
start: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.on('preupdate', this.preUpdate, this);
|
||||
eventEmitter.on('update', this.update, this);
|
||||
eventEmitter.on('shutdown', this.shutdown, this);
|
||||
eventEmitter.on('destroy', this.destroy, this);
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
eventEmitter.once('destroy', this.destroy, this);
|
||||
|
||||
this.timeScale = 1;
|
||||
},
|
||||
|
@ -616,7 +614,8 @@ var TweenManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Scene that owns this manager is shutting down.
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Tweens.TweenManager#shutdown
|
||||
* @since 3.0.0
|
||||
|
@ -631,10 +630,17 @@ var TweenManager = new Class({
|
|||
this._destroy = [];
|
||||
|
||||
this._toProcess = 0;
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.off('preupdate', this.preUpdate, this);
|
||||
eventEmitter.off('update', this.update, this);
|
||||
eventEmitter.off('shutdown', this.shutdown, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that owns this plugin is being destroyed.
|
||||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Tweens.TweenManager#destroy
|
||||
* @since 3.0.0
|
||||
|
@ -642,6 +648,11 @@ var TweenManager = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.scene.sys.events.off('start', this.start, this);
|
||||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -8,7 +8,10 @@ module.exports = {
|
|||
|
||||
context: `${__dirname}/src/`,
|
||||
|
||||
entry: {phaser: './phaser.js'},
|
||||
entry: {
|
||||
phaser: './phaser.js',
|
||||
'phaser-core': './phaser-core.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
path: `${__dirname}/build/`,
|
||||
|
|
|
@ -13,7 +13,9 @@ module.exports = {
|
|||
phaser: './phaser.js',
|
||||
'phaser.min': './phaser.js',
|
||||
'phaser-arcade-physics': './phaser-arcade-physics.js',
|
||||
'phaser-arcade-physics.min': './phaser-arcade-physics.js'
|
||||
'phaser-arcade-physics.min': './phaser-arcade-physics.js',
|
||||
'phaser-core': './phaser-core.js',
|
||||
'phaser-core.min': './phaser-core.js'
|
||||
},
|
||||
|
||||
output: {
|
||||
|
|
Loading…
Add table
Reference in a new issue